Last active
February 10, 2022 10:40
-
-
Save saeedvaziry/2d3892648aee4260f6322f35f2feafa1 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
/** | |
* @param $data | |
* @return string | |
*/ | |
function bpm_encrypt_enc_pan($data) | |
{ | |
return bin2hex(openssl_encrypt(hex2bin($data), 'des-ecb', hex2bin('2C7D202B960A96AA'), OPENSSL_NO_PADDING)); | |
} | |
/** | |
* @param $data | |
* @return string | |
*/ | |
function bpm_encrypt_enc($data) | |
{ | |
return bin2hex(openssl_encrypt(pkcs_padding(hex2bin($data), 8), 'des-ecb', hex2bin('2C7D202B960A96AA'), OPENSSL_NO_PADDING)); | |
} | |
/** | |
* @param $str | |
* @param $blocksize | |
* @return string | |
*/ | |
function pkcs_padding($str, $blocksize) | |
{ | |
$pad = $blocksize - (strlen($str) % $blocksize); | |
return $str . str_repeat(chr($pad), $pad); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment