3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * It should go without saying that this is insecure. * * Don't use it! * * @ref http://www.cryptofails.com/post/87697461507/46esab-high-quality-cryptography-direct-from */ function encodeString($str){ for($i=0; $i<5;$i++) { $str=strrev(base64_encode($str)); // apply base64 first and then reverse the string } return $str; } function decodeString($str){ for($i=0; $i<5;$i++) { $str=base64_decode(strrev($str)); // apply base64 first and then reverse the string } return $str; } # ~8<~8<~8<~8<~8<~8<~8<~8<~8<~8<~8<~8<~8<~8<~8<~8<~8<~8<~8<~8<~8<~8<~ # $a = array( 'a', 'aaa', 'aaaaaa', str_repeat('a', 126), str_repeat('a', 1024), str_repeat('a', 2048) ); $sizeOfA = count($a); $length = array(); $encoded = array(); for ($i = 0; $i < $sizeOfA; ++$i) { $encoded[$i] = encodeString($a[$i]); $length[$i] = strlen($encoded[$i]); } var_dump($length); var_dump($encoded);

preferences:
39.79 ms | 402 KiB | 5 Q