Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function base32_decoder(ByVal b321 As String)
- Dim lut As New Dictionary(Of Char, Integer) From {{"A"c, 0}, {"B"c, 1}, {"C"c, 2}, {"D"c, 3}, {"E"c, 4}, {"F"c, 5}, {"G"c, 6}, {"H"c, 7}, {"I"c, 8}, {"J"c, 9}, {"K"c, 10}, {"L"c, 11}, {"M"c, 12}, {"N"c, 13}, {"O"c, 14}, {"P"c, 15}, {"Q"c, 16}, {"R"c, 17}, {"S"c, 18}, {"T"c, 19}, {"U"c, 20}, {"V"c, 21}, {"W"c, 22}, {"X"c, 23}, {"Y"c, 24}, {"Z"c, 25}, {"2"c, 26}, {"3"c, 27}, {"4"c, 28}, {"5"c, 29}, {"6"c, 30}, {"7"c, 31}}
- Dim b32 As String = b321.ToUpper
- Dim l As Integer = b321.Length
- Dim n As Integer = 0
- Dim j As Integer = 0
- Dim binary = New List(Of Char)
- For i As Integer = 0 To l - 1
- n = n << 5
- n = n + lut(b32(i))
- j = j + 5
- If j >= 8 Then
- j = j - 8
- binary.Add(Chr((n And (&HFF << j)) >> j).ToString.PadLeft(2, "0"))
- End If
- Next
- Return System.Text.Encoding.UTF8.GetBytes(New String(binary.ToArray()))
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement