Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7916015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:39:03+00:00 2026-06-03T14:39:03+00:00

I need to decrypt encrypted POST value strings with the aid of a secret

  • 0

I need to decrypt encrypted POST value strings with the aid of a secret static key.

I have had a look into crypt() (but it’s only one-way) and Mcrypt, GnuPG,… but I’m not happy with them. I think they are to complex for my simple issue. What should I use? I don’t need IV shapes or super safe algorithms. Is there any basic PHP function, that I don’t know yet?

I just need to hide image pathes from users like that:
ImageJPEG(ImageCreateFromJPEG( decode($_REQUEST[‘encryptedImage’],’secret Key’) ));

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T14:39:04+00:00Added an answer on June 3, 2026 at 2:39 pm

    Update (27/09/17):

    Since mcrypt_encrypt is DEPRECATED as of PHP 7.1.0. Ive added a simple encrypt/decrypt using openssl.

    function encrypt($string, $key = 'PrivateKey', $secret = 'SecretKey', $method = 'AES-256-CBC') {
        // hash
        $key = hash('sha256', $key);
        // create iv - encrypt method AES-256-CBC expects 16 bytes
        $iv = substr(hash('sha256', $secret), 0, 16);
        // encrypt
        $output = openssl_encrypt($string, $method, $key, 0, $iv);
        // encode
        return base64_encode($output);
    }
    
    function decrypt($string, $key = 'PrivateKey', $secret = 'SecretKey', $method = 'AES-256-CBC') {
        // hash
        $key = hash('sha256', $key);
        // create iv - encrypt method AES-256-CBC expects 16 bytes
        $iv = substr(hash('sha256', $secret), 0, 16);
        // decode
        $string = base64_decode($string);
        // decrypt
        return openssl_decrypt($string, $method, $key, 0, $iv);
    }
    
    $str = 'Encrypt this text';
    echo "Plain: " .$str. "\n";
    
    // encrypt
    $encrypted_str = encrypt($str);
    echo "Encrypted: " .$encrypted_str. "\n";
    
    // decrypt
    $decrypted_str = decrypt($encrypted_str);
    echo "Decrypted: " .$decrypted_str. "\n";
    

    Original Answer:

    Cant get simpler then this: (PHP < 7.1.0):

    <?php 
    define('SECRET',md5('Some secret key'));
    
    function encrypt($value){
        $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
        $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
        return mcrypt_encrypt(MCRYPT_RIJNDAEL_256, SECRET, $value, MCRYPT_MODE_ECB, $iv);
    }
    
    function decrypt($value){
        $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
        $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
        return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, SECRET, $value, MCRYPT_MODE_ECB, $iv));
    }
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an encrypted bit of text that I need to decrypt. It's encrypted
I need a way to decrypt encrypted URL request parameters into the original Yii
I have a .NET application. I need to store a text value encrypted in
I need a PHP script to decrypt the RSA encrypted string generated by this
I need to save a db password as an encrypted string and then decrypt
I have over 1000 images and videos that need to be encrypted. Nothing over
I have a IV (initialization vector) and key, also a cryptogram. I need do
So I'm working on an application where I need to decrypt encrypted files.The encryption
In my current iPhone project I need to decrypt zip files which have been
We need to encrypt Strings while storing them with JPA and decrypt it when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.