This is a piece of DES decrypted PHP code.
Refer to routines from http://php.net/manual/zh/function.mcrypt-module-open.php. There's nothing difficult about it.
But after I decrypted the test repeatedly, are the following such invisible garbled.
? ?] Y)? aw#? Y?????] M?/m?2??] C?? F?? V (? I????? ~????? ? e=i "C??????
The majority of the genius found, is because the other side after the encryption, the binary cipher to convert to 16 into the system for me to pass over, such as 13bd5122f55e706d13fb7d0f349a787d19e9d2334e268a15
You see clearly, this can not be used as ciphertext itself, I just because the direct decryption of the 16 binary string so that can not be decrypted. This 16-binary string needs to be passed back to the binary, and then decrypted with the decryption method, you can see the clear text.
The hexadecimal-to-binary method is Hex2bin
Cryptare This function is encrypted decryption, the first parameter is clear text or ciphertext, the second parameter is key, the third parameter 0 means decryption, 1 is encryption.
Note: The encryption may not be used $text = $this->hex2bin ($text); This sentence.
function Hex2bin ($hexData) { $binData = ""; for ($i = 0; $i < strlen ($hexData); $i + = 2) { $binData. = Chr (Hexdec (substr ($hexData, $i, 2))); } return $binData; } function Cryptare ($text, $key, $crypt) { $text = $this->hex2bin ($text); $encrypted _data= ""; $TD = Mcrypt_module_open (' des ', ' ', ' ECB ', '); $iv = Mcrypt_create_iv (Mcrypt_enc_get_iv_size ($TD), mcrypt_dev_random); Mcrypt_generic_init ($TD, $key, $iv); if ($crypt) { $encrypted _data = Mcrypt_generic ($TD, $text); Print $encrypted _data; } else { $encrypted _data = Mdecrypt_generic ($TD, $text); } Mcrypt_generic_deinit ($TD); Mcrypt_module_close ($TD); return $encrypted _data; }