Created
February 23, 2017 14:39
-
-
Save mtrimarchi/766f51866db40ddbaf9c64861a9e1e2f to your computer and use it in GitHub Desktop.
PinDecrypt - Convert encrypted data with DES_ECB using a key
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
<?php | |
/** | |
* | |
* PinDecrypt - Convert encrypted data with DES_ECB using a key | |
* | |
* @param String $Key - The key with which the data was encrypted. | |
* If the provided key size is not supported by the cipher, | |
* the function will emit a warning and return FALSE | |
* @param String $Data - The data that will be decrypted with the given cipher and mode. | |
* If the size of the data is not n * blocksize, the data will be padded with '\0'. | |
* | |
* @return String - Returns the decrypted data as a string or FALSE on failure. | |
* | |
*/ | |
function PinDecrypt( $Key, $Data ) | |
{ | |
$cipher = MCRYPT_DES; | |
$key = pack('H*', $Key); | |
$data = pack('H*', $Data); | |
$mode = MCRYPT_MODE_ECB; | |
return bin2hex( mcrypt_decrypt ( $cipher , $key , $data , $mode, NULL ) ); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment