Advertisement
Guest User

base32_decode

a guest
Apr 24th, 2012
717
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.40 KB | None | 0 0
  1.     static function base32_decode($s)
  2.     {
  3.         static $alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
  4.  
  5.         $tmp = '';
  6.  
  7.         foreach (str_split($s) as $c) {
  8.             if (false === ($v = strpos($alphabet, $c))) {
  9.                 $v = 0;
  10.             }
  11.             $tmp .= sprintf('%05b', $v);
  12.         }
  13.         $args = array_map('bindec', str_split($tmp, 8));
  14.         array_unshift($args, 'C*');
  15.  
  16.         return rtrim(call_user_func_array('pack', $args), "\0");
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement