function urllogin_base64dec in urllogin 8
Same name and namespace in other branches
- 6 urllogin_security.inc \urllogin_base64dec()
- 7 urllogin_security.inc \urllogin_base64dec()
- 2.x urllogin_security.inc \urllogin_base64dec()
Converts a base64url encoded string.
Converts a base64url encoded string into a pair of integers plus an extra byte.
Parameters
int $i: First Integer, passed by reference.
int $j: Second Integer, passed by reference.
string $x: Extra byte, passed by reference.
string $urlstr: Encoded string as base64 with the '=' stripped off the end.
Return value
bool Return TRUE if successful, FALSE if $urlstr was invalid base64url
1 call to urllogin_base64dec()
- urllogin_decode in ./
urllogin_security.inc - Decodes an encoded url string.
File
- ./
urllogin_security.inc, line 141 - Include file for urllogin security functions.
Code
function urllogin_base64dec(&$i, &$j, &$x, $urlstr) {
// Do not use drupal_strlen because this is a binary string, not UTF.
if (strlen($urlstr) != 12) {
// URL wrong length.
return FALSE;
}
// Modify to use base64url decoding and decode
// if (version_compare(PHP_VERSION, '5.2.0', '>=')) {.
$s = base64_decode(strtr($urlstr, '-_,', '+/='), TRUE);
if ($s == FALSE) {
return FALSE;
}
$i = ord($s[0]) << 24 | ord($s[1]) << 16 | ord($s[2]) << 8 | ord($s[3]);
$j = ord($s[4]) << 24 | ord($s[5]) << 16 | ord($s[6]) << 8 | ord($s[7]);
$x = ord($s[8]);
return TRUE;
}