Created
April 9, 2023 16:23
-
-
Save divinity76/f4aff8f07c328f3d4e4650d9d9db4f82 to your computer and use it in GitHub Desktop.
base64 encoded length/efficiency thingy..
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// https://3v4l.org/XsSjl | |
function base64url_encode($data) { | |
return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); | |
} | |
$str=""; | |
for($i=1;$i<30;++$i){ | |
$str.=chr($i); | |
$encoded_base = base64url_encode($str); | |
$encoded_base_length = strlen($encoded_base); | |
$encoded_hex = bin2hex($str); | |
$encoded_hex_length = strlen($encoded_hex); | |
echo "{$i}: base64: {$encoded_base_length}: hex: {$encoded_hex_length}: {$encoded_base}\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment