Created
August 7, 2017 15:49
-
-
Save joshapgar/ae9b0e32d56cd69c992fd6bc6f989d02 to your computer and use it in GitHub Desktop.
Encrypt and Decrypt Data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Encryption: | |
$textToEncrypt = "My Text to Encrypt"; | |
$encryptionMethod = "AES-256-CBC"; | |
$secretHash = "encryptionhash"; | |
$iv = mcrypt_create_iv(16, MCRYPT_RAND); | |
$encryptedText = openssl_encrypt($textToEncrypt,$encryptionMethod,$secretHash, 0, $iv); | |
//Decryption: | |
$decryptedText = openssl_decrypt($encryptedText, $encryptionMethod, $secretHash, 0, $iv); | |
print "My Decrypted Text: ". $decryptedText; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment