TizzyT

TZ_Encoding Improve WIP

Feb 1st, 2015
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 16.17 KB | None | 0 0
  1. Public Class TZ_Encoding
  2.     Private LtrNbr As String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 "
  3.     Private HexTable6 As Byte(,) =
  4.         {{0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 1}, {0, 0, 0, 0, 1, 0},
  5.          {0, 0, 0, 0, 1, 1}, {0, 0, 0, 1, 0, 0}, {0, 0, 0, 1, 0, 1},
  6.          {0, 0, 0, 1, 1, 0}, {0, 0, 0, 1, 1, 1}, {0, 0, 1, 0, 0, 0},
  7.          {0, 0, 1, 0, 0, 1}, {0, 0, 1, 0, 1, 0}, {0, 0, 1, 0, 1, 1},
  8.          {0, 0, 1, 1, 0, 0}, {0, 0, 1, 1, 0, 1}, {0, 0, 1, 1, 1, 0},
  9.          {0, 0, 1, 1, 1, 1}, {0, 1, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 1},
  10.          {0, 1, 0, 0, 1, 0}, {0, 1, 0, 0, 1, 1}, {0, 1, 0, 1, 0, 0},
  11.          {0, 1, 0, 1, 0, 1}, {0, 1, 0, 1, 1, 0}, {0, 1, 0, 1, 1, 1},
  12.          {0, 1, 1, 0, 0, 0}, {0, 1, 1, 0, 0, 1}, {0, 1, 1, 0, 1, 0},
  13.          {0, 1, 1, 0, 1, 1}, {0, 1, 1, 1, 0, 0}, {0, 1, 1, 1, 0, 1},
  14.          {0, 1, 1, 1, 1, 0}, {0, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 0, 0},
  15.          {1, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 1, 0}, {1, 0, 0, 0, 1, 1},
  16.          {1, 0, 0, 1, 0, 0}, {1, 0, 0, 1, 0, 1}, {1, 0, 0, 1, 1, 0},
  17.          {1, 0, 0, 1, 1, 1}, {1, 0, 1, 0, 0, 0}, {1, 0, 1, 0, 0, 1},
  18.          {1, 0, 1, 0, 1, 0}, {1, 0, 1, 0, 1, 1}, {1, 0, 1, 1, 0, 0},
  19.          {1, 0, 1, 1, 0, 1}, {1, 0, 1, 1, 1, 0}, {1, 0, 1, 1, 1, 1},
  20.          {1, 1, 0, 0, 0, 0}, {1, 1, 0, 0, 0, 1}, {1, 1, 0, 0, 1, 0},
  21.          {1, 1, 0, 0, 1, 1}, {1, 1, 0, 1, 0, 0}, {1, 1, 0, 1, 0, 1},
  22.          {1, 1, 0, 1, 1, 0}, {1, 1, 0, 1, 1, 1}, {1, 1, 1, 0, 0, 0},
  23.          {1, 1, 1, 0, 0, 1}, {1, 1, 1, 0, 1, 0}, {1, 1, 1, 0, 1, 1},
  24.          {1, 1, 1, 1, 0, 0}, {1, 1, 1, 1, 0, 1}, {1, 1, 1, 1, 1, 0}}
  25.     Private HexTable8 As Byte(,) =
  26.         {{0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 1}, {0, 0, 0, 0, 0, 0, 1, 0}, {0, 0, 0, 0, 0, 0, 1, 1},
  27.          {0, 0, 0, 0, 0, 1, 0, 0}, {0, 0, 0, 0, 0, 1, 0, 1}, {0, 0, 0, 0, 0, 1, 1, 0}, {0, 0, 0, 0, 0, 1, 1, 1},
  28.          {0, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 1, 0, 0, 1}, {0, 0, 0, 0, 1, 0, 1, 0}, {0, 0, 0, 0, 1, 0, 1, 1},
  29.          {0, 0, 0, 0, 1, 1, 0, 0}, {0, 0, 0, 0, 1, 1, 0, 1}, {0, 0, 0, 0, 1, 1, 1, 0}, {0, 0, 0, 0, 1, 1, 1, 1},
  30.          {0, 0, 0, 1, 0, 0, 0, 0}, {0, 0, 0, 1, 0, 0, 0, 1}, {0, 0, 0, 1, 0, 0, 1, 0}, {0, 0, 0, 1, 0, 0, 1, 1},
  31.          {0, 0, 0, 1, 0, 1, 0, 0}, {0, 0, 0, 1, 0, 1, 0, 1}, {0, 0, 0, 1, 0, 1, 1, 0}, {0, 0, 0, 1, 0, 1, 1, 1},
  32.          {0, 0, 0, 1, 1, 0, 0, 0}, {0, 0, 0, 1, 1, 0, 0, 1}, {0, 0, 0, 1, 1, 0, 1, 0}, {0, 0, 0, 1, 1, 0, 1, 1},
  33.          {0, 0, 0, 1, 1, 1, 0, 0}, {0, 0, 0, 1, 1, 1, 0, 1}, {0, 0, 0, 1, 1, 1, 1, 0}, {0, 0, 0, 1, 1, 1, 1, 1},
  34.          {0, 0, 1, 0, 0, 0, 0, 0}, {0, 0, 1, 0, 0, 0, 0, 1}, {0, 0, 1, 0, 0, 0, 1, 0}, {0, 0, 1, 0, 0, 0, 1, 1},
  35.          {0, 0, 1, 0, 0, 1, 0, 0}, {0, 0, 1, 0, 0, 1, 0, 1}, {0, 0, 1, 0, 0, 1, 1, 0}, {0, 0, 1, 0, 0, 1, 1, 1},
  36.          {0, 0, 1, 0, 1, 0, 0, 0}, {0, 0, 1, 0, 1, 0, 0, 1}, {0, 0, 1, 0, 1, 0, 1, 0}, {0, 0, 1, 0, 1, 0, 1, 1},
  37.          {0, 0, 1, 0, 1, 1, 0, 0}, {0, 0, 1, 0, 1, 1, 0, 1}, {0, 0, 1, 0, 1, 1, 1, 0}, {0, 0, 1, 0, 1, 1, 1, 1},
  38.          {0, 0, 1, 1, 0, 0, 0, 0}, {0, 0, 1, 1, 0, 0, 0, 1}, {0, 0, 1, 1, 0, 0, 1, 0}, {0, 0, 1, 1, 0, 0, 1, 1},
  39.          {0, 0, 1, 1, 0, 1, 0, 0}, {0, 0, 1, 1, 0, 1, 0, 1}, {0, 0, 1, 1, 0, 1, 1, 0}, {0, 0, 1, 1, 0, 1, 1, 1},
  40.          {0, 0, 1, 1, 1, 0, 0, 0}, {0, 0, 1, 1, 1, 0, 0, 1}, {0, 0, 1, 1, 1, 0, 1, 0}, {0, 0, 1, 1, 1, 0, 1, 1},
  41.          {0, 0, 1, 1, 1, 1, 0, 0}, {0, 0, 1, 1, 1, 1, 0, 1}, {0, 0, 1, 1, 1, 1, 1, 0}, {0, 0, 1, 1, 1, 1, 1, 1},
  42.          {0, 1, 0, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0, 0, 1}, {0, 1, 0, 0, 0, 0, 1, 0}, {0, 1, 0, 0, 0, 0, 1, 1},
  43.          {0, 1, 0, 0, 0, 1, 0, 0}, {0, 1, 0, 0, 0, 1, 0, 1}, {0, 1, 0, 0, 0, 1, 1, 0}, {0, 1, 0, 0, 0, 1, 1, 1},
  44.          {0, 1, 0, 0, 1, 0, 0, 0}, {0, 1, 0, 0, 1, 0, 0, 1}, {0, 1, 0, 0, 1, 0, 1, 0}, {0, 1, 0, 0, 1, 0, 1, 1},
  45.          {0, 1, 0, 0, 1, 1, 0, 0}, {0, 1, 0, 0, 1, 1, 0, 1}, {0, 1, 0, 0, 1, 1, 1, 0}, {0, 1, 0, 0, 1, 1, 1, 1},
  46.          {0, 1, 0, 1, 0, 0, 0, 0}, {0, 1, 0, 1, 0, 0, 0, 1}, {0, 1, 0, 1, 0, 0, 1, 0}, {0, 1, 0, 1, 0, 0, 1, 1},
  47.          {0, 1, 0, 1, 0, 1, 0, 0}, {0, 1, 0, 1, 0, 1, 0, 1}, {0, 1, 0, 1, 0, 1, 1, 0}, {0, 1, 0, 1, 0, 1, 1, 1},
  48.          {0, 1, 0, 1, 1, 0, 0, 0}, {0, 1, 0, 1, 1, 0, 0, 1}, {0, 1, 0, 1, 1, 0, 1, 0}, {0, 1, 0, 1, 1, 0, 1, 1},
  49.          {0, 1, 0, 1, 1, 1, 0, 0}, {0, 1, 0, 1, 1, 1, 0, 1}, {0, 1, 0, 1, 1, 1, 1, 0}, {0, 1, 0, 1, 1, 1, 1, 1},
  50.          {0, 1, 1, 0, 0, 0, 0, 0}, {0, 1, 1, 0, 0, 0, 0, 1}, {0, 1, 1, 0, 0, 0, 1, 0}, {0, 1, 1, 0, 0, 0, 1, 1},
  51.          {0, 1, 1, 0, 0, 1, 0, 0}, {0, 1, 1, 0, 0, 1, 0, 1}, {0, 1, 1, 0, 0, 1, 1, 0}, {0, 1, 1, 0, 0, 1, 1, 1},
  52.          {0, 1, 1, 0, 1, 0, 0, 0}, {0, 1, 1, 0, 1, 0, 0, 1}, {0, 1, 1, 0, 1, 0, 1, 0}, {0, 1, 1, 0, 1, 0, 1, 1},
  53.          {0, 1, 1, 0, 1, 1, 0, 0}, {0, 1, 1, 0, 1, 1, 0, 1}, {0, 1, 1, 0, 1, 1, 1, 0}, {0, 1, 1, 0, 1, 1, 1, 1},
  54.          {0, 1, 1, 1, 0, 0, 0, 0}, {0, 1, 1, 1, 0, 0, 0, 1}, {0, 1, 1, 1, 0, 0, 1, 0}, {0, 1, 1, 1, 0, 0, 1, 1},
  55.          {0, 1, 1, 1, 0, 1, 0, 0}, {0, 1, 1, 1, 0, 1, 0, 1}, {0, 1, 1, 1, 0, 1, 1, 0}, {0, 1, 1, 1, 0, 1, 1, 1},
  56.          {0, 1, 1, 1, 1, 0, 0, 0}, {0, 1, 1, 1, 1, 0, 0, 1}, {0, 1, 1, 1, 1, 0, 1, 0}, {0, 1, 1, 1, 1, 0, 1, 1},
  57.          {0, 1, 1, 1, 1, 1, 0, 0}, {0, 1, 1, 1, 1, 1, 0, 1}, {0, 1, 1, 1, 1, 1, 1, 0}, {0, 1, 1, 1, 1, 1, 1, 1},
  58.          {1, 0, 0, 0, 0, 0, 0, 0}, {1, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 1, 0}, {1, 0, 0, 0, 0, 0, 1, 1},
  59.          {1, 0, 0, 0, 0, 1, 0, 0}, {1, 0, 0, 0, 0, 1, 0, 1}, {1, 0, 0, 0, 0, 1, 1, 0}, {1, 0, 0, 0, 0, 1, 1, 1},
  60.          {1, 0, 0, 0, 1, 0, 0, 0}, {1, 0, 0, 0, 1, 0, 0, 1}, {1, 0, 0, 0, 1, 0, 1, 0}, {1, 0, 0, 0, 1, 0, 1, 1},
  61.          {1, 0, 0, 0, 1, 1, 0, 0}, {1, 0, 0, 0, 1, 1, 0, 1}, {1, 0, 0, 0, 1, 1, 1, 0}, {1, 0, 0, 0, 1, 1, 1, 1},
  62.          {1, 0, 0, 1, 0, 0, 0, 0}, {1, 0, 0, 1, 0, 0, 0, 1}, {1, 0, 0, 1, 0, 0, 1, 0}, {1, 0, 0, 1, 0, 0, 1, 1},
  63.          {1, 0, 0, 1, 0, 1, 0, 0}, {1, 0, 0, 1, 0, 1, 0, 1}, {1, 0, 0, 1, 0, 1, 1, 0}, {1, 0, 0, 1, 0, 1, 1, 1},
  64.          {1, 0, 0, 1, 1, 0, 0, 0}, {1, 0, 0, 1, 1, 0, 0, 1}, {1, 0, 0, 1, 1, 0, 1, 0}, {1, 0, 0, 1, 1, 0, 1, 1},
  65.          {1, 0, 0, 1, 1, 1, 0, 0}, {1, 0, 0, 1, 1, 1, 0, 1}, {1, 0, 0, 1, 1, 1, 1, 0}, {1, 0, 0, 1, 1, 1, 1, 1},
  66.          {1, 0, 1, 0, 0, 0, 0, 0}, {1, 0, 1, 0, 0, 0, 0, 1}, {1, 0, 1, 0, 0, 0, 1, 0}, {1, 0, 1, 0, 0, 0, 1, 1},
  67.          {1, 0, 1, 0, 0, 1, 0, 0}, {1, 0, 1, 0, 0, 1, 0, 1}, {1, 0, 1, 0, 0, 1, 1, 0}, {1, 0, 1, 0, 0, 1, 1, 1},
  68.          {1, 0, 1, 0, 1, 0, 0, 0}, {1, 0, 1, 0, 1, 0, 0, 1}, {1, 0, 1, 0, 1, 0, 1, 0}, {1, 0, 1, 0, 1, 0, 1, 1},
  69.          {1, 0, 1, 0, 1, 1, 0, 0}, {1, 0, 1, 0, 1, 1, 0, 1}, {1, 0, 1, 0, 1, 1, 1, 0}, {1, 0, 1, 0, 1, 1, 1, 1},
  70.          {1, 0, 1, 1, 0, 0, 0, 0}, {1, 0, 1, 1, 0, 0, 0, 1}, {1, 0, 1, 1, 0, 0, 1, 0}, {1, 0, 1, 1, 0, 0, 1, 1},
  71.          {1, 0, 1, 1, 0, 1, 0, 0}, {1, 0, 1, 1, 0, 1, 0, 1}, {1, 0, 1, 1, 0, 1, 1, 0}, {1, 0, 1, 1, 0, 1, 1, 1},
  72.          {1, 0, 1, 1, 1, 0, 0, 0}, {1, 0, 1, 1, 1, 0, 0, 1}, {1, 0, 1, 1, 1, 0, 1, 0}, {1, 0, 1, 1, 1, 0, 1, 1},
  73.          {1, 0, 1, 1, 1, 1, 0, 0}, {1, 0, 1, 1, 1, 1, 0, 1}, {1, 0, 1, 1, 1, 1, 1, 0}, {1, 0, 1, 1, 1, 1, 1, 1},
  74.          {1, 1, 0, 0, 0, 0, 0, 0}, {1, 1, 0, 0, 0, 0, 0, 1}, {1, 1, 0, 0, 0, 0, 1, 0}, {1, 1, 0, 0, 0, 0, 1, 1},
  75.          {1, 1, 0, 0, 0, 1, 0, 0}, {1, 1, 0, 0, 0, 1, 0, 1}, {1, 1, 0, 0, 0, 1, 1, 0}, {1, 1, 0, 0, 0, 1, 1, 1},
  76.          {1, 1, 0, 0, 1, 0, 0, 0}, {1, 1, 0, 0, 1, 0, 0, 1}, {1, 1, 0, 0, 1, 0, 1, 0}, {1, 1, 0, 0, 1, 0, 1, 1},
  77.          {1, 1, 0, 0, 1, 1, 0, 0}, {1, 1, 0, 0, 1, 1, 0, 1}, {1, 1, 0, 0, 1, 1, 1, 0}, {1, 1, 0, 0, 1, 1, 1, 1},
  78.          {1, 1, 0, 1, 0, 0, 0, 0}, {1, 1, 0, 1, 0, 0, 0, 1}, {1, 1, 0, 1, 0, 0, 1, 0}, {1, 1, 0, 1, 0, 0, 1, 1},
  79.          {1, 1, 0, 1, 0, 1, 0, 0}, {1, 1, 0, 1, 0, 1, 0, 1}, {1, 1, 0, 1, 0, 1, 1, 0}, {1, 1, 0, 1, 0, 1, 1, 1},
  80.          {1, 1, 0, 1, 1, 0, 0, 0}, {1, 1, 0, 1, 1, 0, 0, 1}, {1, 1, 0, 1, 1, 0, 1, 0}, {1, 1, 0, 1, 1, 0, 1, 1},
  81.          {1, 1, 0, 1, 1, 1, 0, 0}, {1, 1, 0, 1, 1, 1, 0, 1}, {1, 1, 0, 1, 1, 1, 1, 0}, {1, 1, 0, 1, 1, 1, 1, 1},
  82.          {1, 1, 1, 0, 0, 0, 0, 0}, {1, 1, 1, 0, 0, 0, 0, 1}, {1, 1, 1, 0, 0, 0, 1, 0}, {1, 1, 1, 0, 0, 0, 1, 1},
  83.          {1, 1, 1, 0, 0, 1, 0, 0}, {1, 1, 1, 0, 0, 1, 0, 1}, {1, 1, 1, 0, 0, 1, 1, 0}, {1, 1, 1, 0, 0, 1, 1, 1},
  84.          {1, 1, 1, 0, 1, 0, 0, 0}, {1, 1, 1, 0, 1, 0, 0, 1}, {1, 1, 1, 0, 1, 0, 1, 0}, {1, 1, 1, 0, 1, 0, 1, 1},
  85.          {1, 1, 1, 0, 1, 1, 0, 0}, {1, 1, 1, 0, 1, 1, 0, 1}, {1, 1, 1, 0, 1, 1, 1, 0}, {1, 1, 1, 0, 1, 1, 1, 1},
  86.          {1, 1, 1, 1, 0, 0, 0, 0}, {1, 1, 1, 1, 0, 0, 0, 1}, {1, 1, 1, 1, 0, 0, 1, 0}, {1, 1, 1, 1, 0, 0, 1, 1},
  87.          {1, 1, 1, 1, 0, 1, 0, 0}, {1, 1, 1, 1, 0, 1, 0, 1}, {1, 1, 1, 1, 0, 1, 1, 0}, {1, 1, 1, 1, 0, 1, 1, 1},
  88.          {1, 1, 1, 1, 1, 0, 0, 0}, {1, 1, 1, 1, 1, 0, 0, 1}, {1, 1, 1, 1, 1, 0, 1, 0}, {1, 1, 1, 1, 1, 0, 1, 1},
  89.          {1, 1, 1, 1, 1, 1, 0, 0}, {1, 1, 1, 1, 1, 1, 0, 1}, {1, 1, 1, 1, 1, 1, 1, 0}, {1, 1, 1, 1, 1, 1, 1, 1}}
  90.  
  91.     Public Function Encode(ByVal Message As String) As Byte()
  92.         If Message = String.Empty Then Return {}
  93.         Dim FinalMessage As New List(Of Byte)
  94.         Dim OptMessage As New List(Of Byte)
  95.         Dim Bit As Integer
  96.         OptMessage.Add(1) : OptMessage.Add(0)
  97.         For i = 0 To Message.Length - 1
  98.             Bit = LtrNbr.IndexOf(Message(i))
  99.             If Bit = -1 Then
  100.                 FinalMessage.AddRange(System.Text.Encoding.UTF8.GetBytes(Message(i)))
  101.                 OptMessage.Add(1)
  102.                 OptMessage.Add(1)
  103.                 OptMessage.Add(1)
  104.                 OptMessage.Add(1)
  105.                 OptMessage.Add(1)
  106.                 OptMessage.Add(1)
  107.             Else
  108.                 OptMessage.Add(HexTable6(Bit, 0))
  109.                 OptMessage.Add(HexTable6(Bit, 1))
  110.                 OptMessage.Add(HexTable6(Bit, 2))
  111.                 OptMessage.Add(HexTable6(Bit, 3))
  112.                 OptMessage.Add(HexTable6(Bit, 4))
  113.                 OptMessage.Add(HexTable6(Bit, 5))
  114.             End If
  115.         Next
  116.         Bit = OptMessage.Count Mod 8
  117.         If Not Bit = 0 Then For i = 1 To 8 - Bit : OptMessage.Add(1) : Next
  118.         For i = 0 To OptMessage.Count - 1 Step 8
  119.             Bit = 0
  120.             If OptMessage(i) = 1 Then Bit += 128
  121.             If OptMessage(i + 1) = 1 Then Bit += 64
  122.             If OptMessage(i + 2) = 1 Then Bit += 32
  123.             If OptMessage(i + 3) = 1 Then Bit += 16
  124.             If OptMessage(i + 4) = 1 Then Bit += 8
  125.             If OptMessage(i + 5) = 1 Then Bit += 4
  126.             If OptMessage(i + 6) = 1 Then Bit += 2
  127.             If OptMessage(i + 7) = 1 Then Bit += 1
  128.             FinalMessage.Add(Bit)
  129.         Next
  130.         Return FinalMessage.ToArray
  131.     End Function
  132.  
  133.     Public Function Decode(ByVal Message() As Byte) As String
  134.         If Message.Length = 0 Then Return String.Empty
  135.         Dim FinalMessage As New System.Text.StringBuilder
  136.         Dim SpcChars As New System.Text.StringBuilder
  137.         Dim NbrOfSpcChar As UInteger = 0
  138.         Dim Bit As Byte = 0
  139.         Dim Phase As Byte = 1
  140.         Dim Rmdr As Byte = 0
  141.         Dim spcindex As UInteger = 0
  142.         For i = 0 To Message.Length - 1
  143.             Select Case Message(i)
  144.                 Case Is > 251 : i += 5
  145.                 Case Is > 247 : i += 4
  146.                 Case Is > 239 : i += 3
  147.                 Case Is > 223 : i += 2
  148.                 Case Is > 191 : i += 1
  149.                 Case Is > 127
  150.                     SpcChars.Append(System.Text.Encoding.UTF8.GetString(Message.Take(i).ToArray))
  151.                     Message = Message.Skip(i).ToArray
  152.                     Exit For
  153.             End Select
  154.             NbrOfSpcChar += 1
  155.             If i = Message.Length - 1 Then Return System.Text.Encoding.UTF8.GetString(Message)
  156.         Next
  157.         If HexTable8(Message(0), 2) = 1 Then Bit += 32
  158.         If HexTable8(Message(0), 3) = 1 Then Bit += 16
  159.         If HexTable8(Message(0), 4) = 1 Then Bit += 8
  160.         If HexTable8(Message(0), 5) = 1 Then Bit += 4
  161.         If HexTable8(Message(0), 6) = 1 Then Bit += 2
  162.         If HexTable8(Message(0), 7) = 1 Then Bit += 1
  163.         If Bit = 63 Then
  164.             If NbrOfSpcChar = 0 Then
  165.                 Return FinalMessage.ToString
  166.             Else
  167.                 FinalMessage.Append(SpcChars(spcindex))
  168.                 spcindex += 1
  169.                 NbrOfSpcChar -= 1
  170.             End If
  171.         Else
  172.             FinalMessage.Append(LtrNbr(Bit))
  173.         End If
  174.         Bit = 0
  175.         For i = 1 To Message.Length - 1
  176.             Select Case Phase
  177.                 Case 0
  178.                     If HexTable8(Message(i), 0) = 1 Then Bit += 2
  179.                     If HexTable8(Message(i), 1) = 1 Then Bit += 1
  180.                     Bit += Rmdr
  181.                     Rmdr = 0
  182.                     If Not Bit = 63 Then
  183.                         FinalMessage.Append(LtrNbr(Bit))
  184.                     Else
  185.                         If Not NbrOfSpcChar = 0 Then
  186.                             FinalMessage.Append(SpcChars(spcindex))
  187.                             spcindex += 1
  188.                             NbrOfSpcChar -= 1
  189.                         Else
  190.                             Exit For
  191.                         End If
  192.                     End If
  193.                     Bit = 0
  194.                     If HexTable8(Message(i), 2) = 1 Then Bit += 32
  195.                     If HexTable8(Message(i), 3) = 1 Then Bit += 16
  196.                     If HexTable8(Message(i), 4) = 1 Then Bit += 8
  197.                     If HexTable8(Message(i), 5) = 1 Then Bit += 4
  198.                     If HexTable8(Message(i), 6) = 1 Then Bit += 2
  199.                     If HexTable8(Message(i), 7) = 1 Then Bit += 1
  200.                     If Not Bit = 63 Then
  201.                         FinalMessage.Append(LtrNbr(Bit))
  202.                     Else
  203.                         If Not NbrOfSpcChar = 0 Then
  204.                             FinalMessage.Append(SpcChars(spcindex))
  205.                             spcindex += 1
  206.                             NbrOfSpcChar -= 1
  207.                         Else
  208.                             Exit For
  209.                         End If
  210.                     End If
  211.                     Bit = 0
  212.                     Phase += 1
  213.                 Case 1
  214.                     If HexTable8(Message(i), 0) = 1 Then Bit += 32
  215.                     If HexTable8(Message(i), 1) = 1 Then Bit += 16
  216.                     If HexTable8(Message(i), 2) = 1 Then Bit += 8
  217.                     If HexTable8(Message(i), 3) = 1 Then Bit += 4
  218.                     If HexTable8(Message(i), 4) = 1 Then Bit += 2
  219.                     If HexTable8(Message(i), 5) = 1 Then Bit += 1
  220.                     If Not Bit = 63 Then
  221.                         FinalMessage.Append(LtrNbr(Bit))
  222.                     Else
  223.                         If Not NbrOfSpcChar = 0 Then
  224.                             FinalMessage.Append(SpcChars(spcindex))
  225.                             spcindex += 1
  226.                             NbrOfSpcChar -= 1
  227.                         Else
  228.                             Exit For
  229.                         End If
  230.                     End If
  231.                     Bit = 0
  232.                     If HexTable8(Message(i), 6) = 1 Then Rmdr += 32
  233.                     If HexTable8(Message(i), 7) = 1 Then Rmdr += 16
  234.                     Phase += 1
  235.                 Case 2
  236.                     If HexTable8(Message(i), 0) = 1 Then Bit += 8
  237.                     If HexTable8(Message(i), 1) = 1 Then Bit += 4
  238.                     If HexTable8(Message(i), 2) = 1 Then Bit += 2
  239.                     If HexTable8(Message(i), 3) = 1 Then Bit += 1
  240.                     Bit += Rmdr
  241.                     Rmdr = 0
  242.                     If Not Bit = 63 Then
  243.                         FinalMessage.Append(LtrNbr(Bit))
  244.                     Else
  245.                         If Not NbrOfSpcChar = 0 Then
  246.                             FinalMessage.Append(SpcChars(spcindex))
  247.                             spcindex += 1
  248.                             NbrOfSpcChar -= 1
  249.                         Else
  250.                             Exit For
  251.                         End If
  252.                     End If
  253.                     Bit = 0
  254.                     If HexTable8(Message(i), 4) = 1 Then Rmdr += 32
  255.                     If HexTable8(Message(i), 5) = 1 Then Rmdr += 16
  256.                     If HexTable8(Message(i), 6) = 1 Then Rmdr += 8
  257.                     If HexTable8(Message(i), 7) = 1 Then Rmdr += 4
  258.                     Phase = 0
  259.             End Select
  260.         Next
  261.         Return FinalMessage.ToString
  262.     End Function
  263. End Class
Advertisement
Add Comment
Please, Sign In to add comment