Skip to content

Instantly share code, notes, and snippets.

@aprakasa
Created November 5, 2018 17:37
Show Gist options
  • Save aprakasa/83ba7d7b419d2aa27646eecbdcfc3ba5 to your computer and use it in GitHub Desktop.
Save aprakasa/83ba7d7b419d2aa27646eecbdcfc3ba5 to your computer and use it in GitHub Desktop.
<?php
/**
* Encrypt Text
* @link https://shellcreeper.com/?p=2082
*/
function my_encrypt( $plain_text ){
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$h_key = hash('sha256', wp_salt(), TRUE);
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $h_key, $plain_text, MCRYPT_MODE_ECB, $iv));
}
/**
* Decrypt Text
* @link https://shellcreeper.com/?p=2082
*/
function my_decrypt( $encrypted_text ){
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$h_key = hash('sha256', wp_salt(), TRUE);
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $h_key, base64_decode( $encrypted_text ), MCRYPT_MODE_ECB, $iv));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment