Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Encode()
- Dim Text As String = "Hello, world!"
- Dim Code As String = ""
- For Each c In Text
- Dim b = AscW(c)
- b = b And 255
- Code &= If(b And 128, "1", "0") & If(b And 64, "1", "0") & If(b And 32, "1", "0") & If(b And 16, "1", "0") &
- If(b And 8, "1", "0") & If(b And 4, "1", "0") & If(b And 2, "1", "0") & If(b And 1, "1", "0") & " "
- Next
- Console.WriteLine(Code)
- Console.ReadKey(True)
- End Sub
- Sub Decode()
- Dim Code As String = "01001000 01100101 01101100 01101100 01101111 00101100 00100000 01110111 01101111 01110010 01101100 01100100 00100001"
- Dim Text As String = ""
- Dim i As Integer
- For i = 0 To Code.Length - 8 Step 9
- Text &= ChrW(Byte.Parse(Code(i + 0)) << 7 Or
- Byte.Parse(Code(i + 1)) << 6 Or
- Byte.Parse(Code(i + 2)) << 5 Or
- Byte.Parse(Code(i + 3)) << 4 Or
- Byte.Parse(Code(i + 4)) << 3 Or
- Byte.Parse(Code(i + 5)) << 2 Or
- Byte.Parse(Code(i + 6)) << 1 Or
- Byte.Parse(Code(i + 7)) << 0)
- Next
- Console.WriteLine(Text)
- Console.ReadKey(True)
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment