<?php
# --- ENCRYPTION ---
# the key should be random binary, use scrypt, bcrypt or PBKDF2 to
# convert a string into a key
# key is specified using hexadecimal
$key = 'ICS2015';
# show key size use either 16, 24 or 32 byte keys for AES-128, 192
# and 256 respectively
$key_size = strlen($key);
echo "Key size: " . $key_size . "\n";
$plaintext = "boy10@naver.com";
# create a random IV to use with CBC encoding
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
# creates a cipher text compatible with AES (Rijndael block size = 128)
# to keep the text confidential
# only suitable for encoded input that never ends with value 00h
# (because of default zero padding)
$ciphertext = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key,
$plaintext, MCRYPT_MODE_CBC, $iv);
# prepend the IV for it to be available for decryption
$ciphertext = $iv . $ciphertext;
# encode the resulting cipher text so it can be represented by a string
$ciphertext_base64 = base64_encode($ciphertext);
echo $ciphertext_base64 . "\n";
# === WARNING ===
# Resulting cipher text has no integrity or authenticity added
# and is not protected against padding oracle attacks.
# --- DECRYPTION ---
$ciphertext_dec = base64_decode($ciphertext_base64);
# retrieves the IV, iv_size should be created using mcrypt_get_iv_size()
$iv_dec = substr($ciphertext_dec, 0, $iv_size);
# retrieves the cipher text (everything except the $iv_size in the front)
$ciphertext_dec = substr($ciphertext_dec, $iv_size);
# may remove 00h valued characters from end of plain text
$plaintext_dec = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key,
$ciphertext_dec, MCRYPT_MODE_CBC, $iv_dec);
echo $plaintext_dec . "\n";
?>
Key size: 7
Fatal error: Uncaught Error: Call to undefined function mcrypt_get_iv_size() in /in/ho0jH:17
Stack trace:
#0 {main}
thrown in /in/ho0jH on line 17
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Key size: 7
Fatal error: Uncaught Error: Call to undefined function mcrypt_get_iv_size() in /in/ho0jH:17
Stack trace:
#0 {main}
thrown in /in/ho0jH on line 17
Process exited with code 255.
Output for 7.0.5
Key size: 7
Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25
eo90e58BIt+0bPdbNoyMtA==
Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 7.0.4
Key size: 7
Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25
I536Pjd8fZJit5mJahP4mg==
Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 7.0.3
Key size: 7
Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25
FXHuCHGC+L8zN4tSAG1LOQ==
Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 7.0.2
Key size: 7
Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25
Etm1NAK6ZD98vaphPoJg5w==
Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 7.0.1
Key size: 7
Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25
a+D6kiJ15RPq+MhAefNcfg==
Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 7.0.0
Key size: 7
Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25
Uu8GHBvRAFPqA9XVMZZ1fQ==
Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.5.35, 5.6.21 - 5.6.28
Key size: 7
Fatal error: Call to undefined function mcrypt_get_iv_size() in /in/ho0jH on line 17
Process exited with code 255.
Output for 5.6.20
Key size: 7
Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25
yKQK2pZVFzIQOBvrrxDaqg==
Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.19
Key size: 7
Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25
8AJpiVhUEkTgDtLUA+F9cA==
Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.18
Key size: 7
Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25
vXt5ZpIJnp2YIhsXtwgnCg==
Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.17
Key size: 7
Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25
1XtnU47eiIR7Pq+LXNfZUA==
Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.16
Key size: 7
Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25
ruH5xFevuZ671RutrSQdVQ==
Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.15
Key size: 7
Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25
8O6Gk/L8Z0Se1/QySI8DLw==
Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.14
Key size: 7
Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25
gz1CJWumWvbmV0iGq00dAg==
Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.13
Key size: 7
Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25
yKHCw2oYHiBivnLOnHPaZQ==
Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.12
Key size: 7
Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25
QoYZ1PTcK3wcEQUdSLUUKw==
Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.11
Key size: 7
Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25
haa2Bn/L3e3Sckc628/mYA==
Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.10
Key size: 7
Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25
Ev55Yt1wsGsD8AUs/jqGSw==
Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.9
Key size: 7
Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25
4HoLScfZSYQjxHfh5ROHwQ==
Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.8
Key size: 7
Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25
GKRYZSZWcFosJ7wyAlwGyA==
Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52