@ 2017-02-14T06:29:29Z <?php
function base64url_encode($data) {
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}
function base64url_decode($data) {
return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT));
}
function encryptCode($data){
return mcrypt_encrypt( MCRYPT_DES , '12345678' , $data , 'cbc' ,'87654321');
}
function decryptCode($data){
return mcrypt_decrypt( MCRYPT_DES , '12345678' , $data , 'cbc' ,'87654321');
}
$id = 'Q2JmDpmqjNmGT4FJ2EkXXITOgc31ZA52';
$base64Decoded = base64url_decode($id);
$decrypted = decryptCode($base64Decoded);
print_r($decrypted."\n");
print_r("\n\n");
# Make the new plaintext string
$toAdd = 'hellothere';
$additionalCipherText = encryptCode($toAdd);
$additionalEncoded = base64url_encode($additionalCipherText);
print_r("Additional cipher text:".$additionalEncoded."\n");
print_r("\n\n");
# Concatenate the plaintext and encrypt
$plaintext = $decrypted.$toAdd;
$cipherText = encryptCode($plaintext);
$base64Encoded = base64url_encode($cipherText);
print_r(" New cipher text: ".$base64Encoded."\n");
print_r("Original cipher text: ".$id.$additionalEncoded."\n");
# Try the reverse order
$plaintext = $toAdd.$decrypted;
$cipherText = encryptCode($plaintext);
$base64Encoded = base64url_encode($cipherText);
print_r(" New cipher text: ".$base64Encoded."\n");
print_r("Original cipher text: ".$additionalEncoded.$id."\n");
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.0.0 - 7.0.20 , 7.1.0 - 7.1.20 , 7.2.0 - 7.2.33 , 7.3.16 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.30 , 8.2.0 - 8.2.25 , 8.3.0 - 8.3.13 Fatal error: Uncaught Error: Call to undefined function mcrypt_decrypt() in /in/nv7UJ:16
Stack trace:
#0 /in/nv7UJ(21): decryptCode('Cbf\x0E\x99\xAA\x8C\xD9\x86O\x81I\xD8I\x17...')
#1 {main}
thrown in /in/nv7UJ on line 16
Process exited with code 255 . preferences:dark mode live preview
73.63 ms | 408 KiB | 5 Q