ibennz

LBE_Encryption

Feb 22nd, 2014
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.43 KB | None | 0 0
  1. 'Credits : ibennz
  2. Public Class Form1
  3.  
  4.     Private mByte As Byte() = {}
  5.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  6.         Dim tmp As String = "Hello"
  7.         mByte = LBE_Encrypt(System.Text.Encoding.UTF8.GetBytes(tmp), New Byte() {0, 2, 4})
  8.         MsgBox(mByte.Length)
  9.     End Sub
  10.     Private Function LBE_Encrypt(data As Byte(), pass As Byte()) As Byte()
  11.         Dim out As New List(Of Byte)
  12.         Dim c As Integer = 0
  13.         For Each b As Byte In data
  14.             If c >= pass.Length Then : c = 0 : End If
  15.             If CInt(b) + CInt(pass(c)) < 255 Then
  16.                 out.Add(b + pass(c))
  17.             Else
  18.                 out.Add(b - pass(c))
  19.             End If
  20.         Next
  21.         Return out.ToArray
  22.     End Function
  23.     Private Function LBE_Decrypt(data As Byte(), pass As Byte()) As Byte()
  24.         Dim out As New List(Of Byte)
  25.         Dim c As Integer = 0
  26.         For Each b As Byte In data
  27.             If c >= pass.Length Then : c = 0 : End If
  28.             If CInt(b) + CInt(pass(c)) < 255 Then
  29.                 out.Add(b - pass(c))
  30.             Else
  31.                 out.Add(b + pass(c))
  32.             End If
  33.         Next
  34.         Return out.ToArray
  35.     End Function
  36.  
  37.     Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  38.         MsgBox(System.Text.Encoding.UTF8.GetString(LBE_Decrypt(mByte, New Byte() {0, 2, 4})))
  39.     End Sub
  40. End Class
Advertisement
Add Comment
Please, Sign In to add comment