Skip to content

Instantly share code, notes, and snippets.

@saeedvaziry
Last active February 10, 2022 10:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saeedvaziry/2d3892648aee4260f6322f35f2feafa1 to your computer and use it in GitHub Desktop.
Save saeedvaziry/2d3892648aee4260f6322f35f2feafa1 to your computer and use it in GitHub Desktop.
<?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