Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1. function EncryptThis($ClearTextData) {
  2.             global $ENCRYPTION_KEY;
  3.             global $ENCRYPTION_ALGORITHM;
  4.             $EncryptionKey = base64_decode($ENCRYPTION_KEY);
  5.             $InitializationVector  = openssl_random_pseudo_bytes(openssl_cipher_iv_length($ENCRYPTION_ALGORITHM));
  6.             $EncryptedText = openssl_encrypt($ClearTextData, $ENCRYPTION_ALGORITHM, $EncryptionKey, 0, $InitializationVector);
  7.             return base64_encode($EncryptedText . '::' . $InitializationVector);
  8.         }
  9.         function DecryptThis($CipherData) {
  10.             global $ENCRYPTION_KEY;
  11.             global $ENCRYPTION_ALGORITHM;
  12.             $EncryptionKey = base64_decode($ENCRYPTION_KEY);
  13.             list($Encrypted_Data, $InitializationVector ) = array_pad(explode('::', base64_decode($CipherData), 2), 2, null);
  14.             return openssl_decrypt($Encrypted_Data, $ENCRYPTION_ALGORITHM, $EncryptionKey, 0, $InitializationVector);
  15.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement