Created
July 12, 2018 03:15
-
-
Save felipelavinz/16f6131e94819f25a9032a721af271f0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function base64ToBits( $validFor ) { | |
if ( empty( $validFor ) ) { | |
return ''; | |
} | |
$validForBits = ''; | |
$validForArr = str_split( $validFor ); | |
$base64Chars = str_split('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'); | |
for ( $i = 0; $i < count( $validForArr ); $i++ ) { | |
$thisChar = $validForArr[ $i ]; | |
$val = array_search( $thisChar, $base64Chars ); | |
$bits = str_pad( decbin( $val ), 6, '0', STR_PAD_LEFT ); | |
$validForBits .= $bits; | |
} | |
return $validForBits; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment