Passport decryption function written in php
/**
- * Passport decryption function
- *
- * @ Param string the encrypted string
- * @ Param string private key (used for decryption and encryption)
- *
- * @ Return string result after private key decryption
- */
- Function passport_decrypt ($ txt, $ key ){
// $ Txt results in base64 decoding of the encrypted string, and then together with the private key,
- // Return value after passport_key () function processing
- $ Txt = passport_key (base64_decode ($ txt), $ key );
// Variable initialization
- $ Tmp = '';
// For loop, $ I is an integer starting from 0 to less than $ txt string length
- For ($ I = 0; $ I <strlen ($ txt); $ I ++ ){
- // $ Tmp adds a bit at the end of the string, whose content is the $ I bit of $ txt,
- // It is the same as the $ I + 1 bits in $ txt. Then $ I = $ I + 1
- $ Tmp. = $ txt [$ I] ^ $ txt [++ $ I];
- }
// Return the value of $ tmp as the result
- Return $ tmp;
}
/**
- * Passport key processing function
- *
- * @ Param string the string to be encrypted or to be decrypted
- * @ Param string private key (used for decryption and encryption)
- *
- * @ Return string the processed key
- */
- Function passport_key ($ txt, $ encrypt_key ){
// Assign $ encrypt_key to the value of $ encrypt_key after md5 ()
- $ Encrypt_key = md5 ($ encrypt_key );
// Variable initialization
- $ Ctr = 0;
- $ Tmp = '';
// For loop, $ I is an integer starting from 0 to less than $ txt string length
- For ($ I = 0; $ I <strlen ($ txt); $ I ++ ){
- // If $ ctr = $ encrypt_key length, $ ctr is cleared.
- $ Ctr = strlen ($ encrypt_key )? 0: $ ctr;
- // $ Tmp adds a bit at the end of the string, whose content is the $ I bit of $ txt,
- // It is the same or as the $ ctr + 1 of $ encrypt_key. Then $ ctr = $ ctr + 1
- $ Tmp. = $ txt [$ I] ^ $ encrypt_key [$ ctr ++];
- }
// Return the value of $ tmp as the result
- Return $ tmp;
- }
- ?>
|