[VB.NET]PolyCloud Encryption 07-03-2011, 04:08 PM
#1
Code:
Public Class PolyCloud
#Region "Static Functions"
Public Shared Function EncryptData(Input As String, Key As String) As String
Return Convert.ToBase64String(EncryptData(System.Text.Encoding.UTF8.GetBytes(Input), System.Text.Encoding.UTF8.GetBytes(Key)))
End Function
Public Shared Function EncryptData(Input As Byte(), Key As Byte()) As Byte()
Dim Rnd As New Random()
Dim Salt As Integer = Rnd.[Next](1, 50)
Dim FinVal As Byte() = New Byte(Input.Length) {}
FinVal(Input.Length) = CByte(Salt)
Dim kc As Short = 0
For index As Integer = 0 To Input.Length - 1
If kc >= Key.Length Then
kc = 0
End If
FinVal(index) = Convert.ToByte(Input(index) + (Input.Length Mod Key.Length) + (Key(kc)) - Salt)
kc += 1
Next
Return FinVal
End Function
Public Shared Function DecryptData(Input As String, Key As String) As String
Return System.Text.Encoding.UTF8.GetString(DecryptData(Convert.FromBase64String(Input), System.Text.Encoding.UTF8.GetBytes(Key)))
End Function
Public Shared Function DecryptData(Input As Byte(), Key As Byte()) As Byte()
Dim Salt As Integer = CInt(Input(Input.Length - 1))
Dim FinVal As Byte() = New Byte(Input.Length - 2) {}
Dim kc As Short = 0
For index As Integer = 0 To Input.Length - 2
If kc >= Key.Length Then
kc = 0
End If
If index >= Input.Length - 1 Then
Continue For
End If
FinVal(index) = Convert.ToByte(Input(index) - (FinVal.Length Mod Key.Length) - (Key(kc)) + Salt)
kc += 1
Next
Return FinVal
End Function
#End Region
End Class

![[+]](https://sinister.li/images/modern/collapse_collapsed.png)