Jump to content

Eddy

Members
  • Posts

    2
  • Joined

  • Last visited

Eddy's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Here's my short version. I've seen many base64 decoder here and almost all of them are either too slow, too big, or decode incorrectly so I decided to write my own. Take a look for yourself and hopefully it'll help save you some time on base64 decoder. Any feedback is welcome. Happy programming... Func Base64Decode($s) Local $key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', _ $t = '', $p = -8, $a = 0, $c, $d, $len = StringLen($s) For $i = 1 to $len $c = StringInStr($key, StringMid($s,$i,1), 1) - 1 If $c < 0 Then ContinueLoop $a = BitOR(BitShift($a, -6), BitAND($c, 63)) $p = $p + 6 If $p >= 0 Then $d = BitAND(BitShift($a, $p), 255) If $c <> 64 Then $t = $t & Chr($d) $a = BitAND($a, 63) $p = $p - 8 EndIf Next Return $t EndFunc
  2. I've seen many base64 decoder here and almost all of them are either too slow, too big, or decode incorrectly so I decided to write my own. Take a look for yourself and hopefully it'll help save you some time on base64 decoder. Any feedback is welcome. Happy programming... Func Base64Decode($s) Local $key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', _ $t = '', $p = -8, $a = 0, $c, $d, $len = StringLen($s) For $i = 1 to $len $c = StringInStr($key, StringMid($s,$i,1), 1) - 1 If $c < 0 Then ContinueLoop $a = BitOR(BitShift($a, -6), BitAND($c, 63)) $p = $p + 6 If $p >= 0 Then $d = BitAND(BitShift($a, $p), 255) If $c <> 64 Then $t = $t & Chr($d) $a = BitAND($a, 63) $p = $p - 8 EndIf Next Return $t EndFunc
×
×
  • Create New...