Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Text
- Imports System.Text.RegularExpressions
- Imports System.Security.Cryptography
- 'Fonctions de cryptage (http://www.leblogduhacker.fr)
- Public Class Cryptage
- #Region "Atom 128"
- Public Function Atom128_Encode(ByVal input As String) As String
- input = Uri.EscapeDataString(input)
- Dim key As String = "/128GhIoPQROSTeUbADfgHijKLM+n0pFWXY456xyzB7=39VaqrstJklmNuZvwcdEC"
- Dim out As New System.Text.StringBuilder
- Dim i As Integer
- Do
- Dim enc(3) As Integer
- Dim chrs As Integer() = {0, 0, 0}
- For b As Integer = 0 To 2
- If i < input.Length Then chrs(b) = Asc(input(i))
- i += 1
- Next
- enc(0) = chrs(0) >> 2
- enc(1) = ((chrs(0) And 3) << 4) Or (chrs(1) >> 4)
- enc(2) = ((chrs(1) And 15) << 2) Or (chrs(2) >> 6)
- enc(3) = chrs(2) And 63
- If chrs(1) = 0 Then
- enc(2) = 64
- enc(3) = 64
- End If
- If chrs(2) = 0 Then
- enc(3) = 64
- End If
- For Each x As Integer In enc
- out.Append(key(x))
- Next
- Loop While i < input.Length
- Return out.ToString
- End Function
- Public Function Atom128_Decode(ByVal input As String) As String
- Dim key As String = "/128GhIoPQROSTeUbADfgHijKLM+n0pFWXY456xyzB7=39VaqrstJklmNuZvwcdEC"
- Dim out As New System.Text.StringBuilder
- Dim i As Integer
- Do
- Dim enc(3) As Integer
- Dim chrs() As Integer = {0, 0, 0}
- For b As Integer = 0 To 3
- enc(b) = key.IndexOf(input(i))
- i = i + 1
- Next
- chrs(0) = (enc(0) << 2) Or (enc(1) >> 4)
- chrs(1) = (enc(1) And 15) << 4 Or (enc(2) >> 2)
- chrs(2) = (enc(2) And 3) << 6 Or enc(3)
- out.Append(Chr(chrs(0)))
- If enc(2) <> 64 Then out.Append(Chr(chrs(1)))
- If enc(3) <> 64 Then out.Append(Chr(chrs(2)))
- Loop While i < input.Length
- Return out.ToString
- End Function
- #End Region
- #Region "HAZZ 15"
- Public Function HAZZ15_Encode(ByVal input As String) As String
- input = Uri.EscapeDataString(input)
- Dim key As String = "HNO4klm6ij9n+J2hyf0gzA8uvwDEq3X1Q7ZKeFrWcVTts/MRGYbdxSo=ILaUpPBC5"
- Dim out As New System.Text.StringBuilder
- Dim i As Integer
- Do
- Dim enc(3) As Integer
- Dim chrs As Integer() = {0, 0, 0}
- For b As Integer = 0 To 2
- If i < input.Length Then chrs(b) = Asc(input(i))
- i += 1
- Next
- enc(0) = chrs(0) >> 2
- enc(1) = ((chrs(0) And 3) << 4) Or (chrs(1) >> 4)
- enc(2) = ((chrs(1) And 15) << 2) Or (chrs(2) >> 6)
- enc(3) = chrs(2) And 63
- If chrs(1) = 0 Then
- enc(2) = 64
- enc(3) = 64
- End If
- If chrs(2) = 0 Then
- enc(3) = 64
- End If
- For Each x As Integer In enc
- out.Append(key(x))
- Next
- Loop While i < input.Length
- Return out.ToString
- End Function
- Public Function HAZZ15_Decode(ByVal input As String) As String
- Dim key As String = "HNO4klm6ij9n+J2hyf0gzA8uvwDEq3X1Q7ZKeFrWcVTts/MRGYbdxSo=ILaUpPBC5"
- Dim out As New System.Text.StringBuilder
- Dim i As Integer
- Do
- Dim enc(3) As Integer
- Dim chrs() As Integer = {0, 0, 0}
- For b As Integer = 0 To 3
- enc(b) = key.IndexOf(input(i))
- i = i + 1
- Next
- chrs(0) = (enc(0) << 2) Or (enc(1) >> 4)
- chrs(1) = (enc(1) And 15) << 4 Or (enc(2) >> 2)
- chrs(2) = (enc(2) And 3) << 6 Or enc(3)
- out.Append(Chr(chrs(0)))
- If enc(2) <> 64 Then out.Append(Chr(chrs(1)))
- If enc(3) <> 64 Then out.Append(Chr(chrs(2)))
- Loop While i < input.Length
- Return out.ToString
- End Function
- #End Region
- #Region "GILA 7"
- Public Function GILA7_Encode(ByVal input As String) As String
- input = Uri.EscapeDataString(input)
- Dim key As String = "7ZSTJK+W=cVtBCasyf0gzA8uvwDEq3XH/1RMNOILPQU4klm65YbdeFrx2hij9nopG"
- Dim out As New System.Text.StringBuilder
- Dim i As Integer
- Do
- Dim enc(3) As Integer
- Dim chrs As Integer() = {0, 0, 0}
- For b As Integer = 0 To 2
- If i < input.Length Then chrs(b) = Asc(input(i))
- i += 1
- Next
- enc(0) = chrs(0) >> 2
- enc(1) = ((chrs(0) And 3) << 4) Or (chrs(1) >> 4)
- enc(2) = ((chrs(1) And 15) << 2) Or (chrs(2) >> 6)
- enc(3) = chrs(2) And 63
- If chrs(1) = 0 Then
- enc(2) = 64
- enc(3) = 64
- End If
- If chrs(2) = 0 Then
- enc(3) = 64
- End If
- For Each x As Integer In enc
- out.Append(key(x))
- Next
- Loop While i < input.Length
- Return out.ToString
- End Function
- Public Function GILA7_Decode(ByVal input As String) As String
- Dim key As String = "7ZSTJK+W=cVtBCasyf0gzA8uvwDEq3XH/1RMNOILPQU4klm65YbdeFrx2hij9nopG"
- Dim out As New System.Text.StringBuilder
- Dim i As Integer
- Do
- Dim enc(3) As Integer
- Dim chrs() As Integer = {0, 0, 0}
- For b As Integer = 0 To 3
- enc(b) = key.IndexOf(input(i))
- i = i + 1
- Next
- chrs(0) = (enc(0) << 2) Or (enc(1) >> 4)
- chrs(1) = (enc(1) And 15) << 4 Or (enc(2) >> 2)
- chrs(2) = (enc(2) And 3) << 6 Or enc(3)
- out.Append(Chr(chrs(0)))
- If enc(2) <> 64 Then out.Append(Chr(chrs(1)))
- If enc(3) <> 64 Then out.Append(Chr(chrs(2)))
- Loop While i < input.Length
- Return out.ToString
- End Function
- #End Region
- #Region "ESAB 46"
- Public Function ESAB46_Encode(ByVal input As String) As String
- input = Uri.EscapeDataString(input)
- Dim key As String = "ABCDqrs456tuvNOPwxyz012KLM3789=+QRSTUVWXYZabcdefghijklmnopEFGHIJ/"
- Dim out As New System.Text.StringBuilder
- Dim i As Integer
- Do
- Dim enc(3) As Integer
- Dim chrs As Integer() = {0, 0, 0}
- For b As Integer = 0 To 2
- If i < input.Length Then chrs(b) = Asc(input(i))
- i += 1
- Next
- enc(0) = chrs(0) >> 2
- enc(1) = ((chrs(0) And 3) << 4) Or (chrs(1) >> 4)
- enc(2) = ((chrs(1) And 15) << 2) Or (chrs(2) >> 6)
- enc(3) = chrs(2) And 63
- If chrs(1) = 0 Then
- enc(2) = 64
- enc(3) = 64
- End If
- If chrs(2) = 0 Then
- enc(3) = 64
- End If
- For Each x As Integer In enc
- out.Append(key(x))
- Next
- Loop While i < input.Length
- Return out.ToString
- End Function
- Public Function ESAB46_Decode(ByVal input As String) As String
- Dim key As String = "ABCDqrs456tuvNOPwxyz012KLM3789=+QRSTUVWXYZabcdefghijklmnopEFGHIJ/"
- Dim out As New System.Text.StringBuilder
- Dim i As Integer
- Do
- Dim enc(3) As Integer
- Dim chrs() As Integer = {0, 0, 0}
- For b As Integer = 0 To 3
- enc(b) = key.IndexOf(input(i))
- i = i + 1
- Next
- chrs(0) = (enc(0) << 2) Or (enc(1) >> 4)
- chrs(1) = (enc(1) And 15) << 4 Or (enc(2) >> 2)
- chrs(2) = (enc(2) And 3) << 6 Or enc(3)
- out.Append(Chr(chrs(0)))
- If enc(2) <> 64 Then out.Append(Chr(chrs(1)))
- If enc(3) <> 64 Then out.Append(Chr(chrs(2)))
- Loop While i < input.Length
- Return out.ToString
- End Function
- #End Region
- #Region "Megan 35"
- Public Function MEGAN35_Encode(ByVal input As String) As String
- input = Uri.EscapeDataString(input)
- Dim key As String = "3GHIJKLMNOPQRSTUb=cdefghijklmnopWXYZ/12+406789VaqrstuvwxyzABCDEF5"
- Dim out As New System.Text.StringBuilder
- Dim i As Integer
- Do
- Dim enc(3) As Integer
- Dim chrs As Integer() = {0, 0, 0}
- For b As Integer = 0 To 2
- If i < input.Length Then chrs(b) = Asc(input(i))
- i += 1
- Next
- enc(0) = chrs(0) >> 2
- enc(1) = ((chrs(0) And 3) << 4) Or (chrs(1) >> 4)
- enc(2) = ((chrs(1) And 15) << 2) Or (chrs(2) >> 6)
- enc(3) = chrs(2) And 63
- If chrs(1) = 0 Then
- enc(2) = 64
- enc(3) = 64
- End If
- If chrs(2) = 0 Then
- enc(3) = 64
- End If
- For Each x As Integer In enc
- out.Append(key(x))
- Next
- Loop While i < input.Length
- Return out.ToString
- End Function
- Public Function MEGAN35_Decode(ByVal input As String) As String
- Dim key As String = "3GHIJKLMNOPQRSTUb=cdefghijklmnopWXYZ/12+406789VaqrstuvwxyzABCDEF5"
- Dim out As New System.Text.StringBuilder
- Dim i As Integer
- Do
- Dim enc(3) As Integer
- Dim chrs() As Integer = {0, 0, 0}
- For b As Integer = 0 To 3
- enc(b) = key.IndexOf(input(i))
- i = i + 1
- Next
- chrs(0) = (enc(0) << 2) Or (enc(1) >> 4)
- chrs(1) = (enc(1) And 15) << 4 Or (enc(2) >> 2)
- chrs(2) = (enc(2) And 3) << 6 Or enc(3)
- out.Append(Chr(chrs(0)))
- If enc(2) <> 64 Then out.Append(Chr(chrs(1)))
- If enc(3) <> 64 Then out.Append(Chr(chrs(2)))
- Loop While i < input.Length
- Return out.ToString
- End Function
- #End Region
- #Region "Zong 22"
- Public Function ZONG22_Encode(ByVal input As String) As String
- input = Uri.EscapeDataString(input)
- Dim key As String = "ZKj9n+yf0wDVX1s/5YbdxSo=ILaUpPBCHg8uvNO4klm6iJGhQ7eFrWczAMEq3RTt2"
- Dim out As New System.Text.StringBuilder
- Dim i As Integer
- Do
- Dim enc(3) As Integer
- Dim chrs As Integer() = {0, 0, 0}
- For b As Integer = 0 To 2
- If i < input.Length Then chrs(b) = Asc(input(i))
- i += 1
- Next
- enc(0) = chrs(0) >> 2
- enc(1) = ((chrs(0) And 3) << 4) Or (chrs(1) >> 4)
- enc(2) = ((chrs(1) And 15) << 2) Or (chrs(2) >> 6)
- enc(3) = chrs(2) And 63
- If chrs(1) = 0 Then
- enc(2) = 64
- enc(3) = 64
- End If
- If chrs(2) = 0 Then
- enc(3) = 64
- End If
- For Each x As Integer In enc
- out.Append(key(x))
- Next
- Loop While i < input.Length
- Return out.ToString
- End Function
- Public Function ZONG22_Decode(ByVal input As String) As String
- Dim key As String = "ZKj9n+yf0wDVX1s/5YbdxSo=ILaUpPBCHg8uvNO4klm6iJGhQ7eFrWczAMEq3RTt2"
- Dim out As New System.Text.StringBuilder
- Dim i As Integer
- Do
- Dim enc(3) As Integer
- Dim chrs() As Integer = {0, 0, 0}
- For b As Integer = 0 To 3
- enc(b) = key.IndexOf(input(i))
- i = i + 1
- Next
- chrs(0) = (enc(0) << 2) Or (enc(1) >> 4)
- chrs(1) = (enc(1) And 15) << 4 Or (enc(2) >> 2)
- chrs(2) = (enc(2) And 3) << 6 Or enc(3)
- out.Append(Chr(chrs(0)))
- If enc(2) <> 64 Then out.Append(Chr(chrs(1)))
- If enc(3) <> 64 Then out.Append(Chr(chrs(2)))
- Loop While i < input.Length
- Return out.ToString
- End Function
- #End Region
- #Region "Tripo 5"
- Public Function TRIPO5_Encode(ByVal input As String) As String
- input = Uri.EscapeDataString(input)
- Dim key As String = "ghijopE+G78lmnIJQRXY=abcS/UVWdefABCs456tDqruvNOPwx2KLyz01M3Hk9ZFT"
- Dim out As New System.Text.StringBuilder
- Dim i As Integer
- Do
- Dim enc(3) As Integer
- Dim chrs As Integer() = {0, 0, 0}
- For b As Integer = 0 To 2
- If i < input.Length Then chrs(b) = Asc(input(i))
- i += 1
- Next
- enc(0) = chrs(0) >> 2
- enc(1) = ((chrs(0) And 3) << 4) Or (chrs(1) >> 4)
- enc(2) = ((chrs(1) And 15) << 2) Or (chrs(2) >> 6)
- enc(3) = chrs(2) And 63
- If chrs(1) = 0 Then
- enc(2) = 64
- enc(3) = 64
- End If
- If chrs(2) = 0 Then
- enc(3) = 64
- End If
- For Each x As Integer In enc
- out.Append(key(x))
- Next
- Loop While i < input.Length
- Return out.ToString
- End Function
- Public Function TRIPO5_Decode(ByVal input As String) As String
- Dim key As String = "ghijopE+G78lmnIJQRXY=abcS/UVWdefABCs456tDqruvNOPwx2KLyz01M3Hk9ZFT"
- Dim out As New System.Text.StringBuilder
- Dim i As Integer
- Do
- Dim enc(3) As Integer
- Dim chrs() As Integer = {0, 0, 0}
- For b As Integer = 0 To 3
- enc(b) = key.IndexOf(input(i))
- i = i + 1
- Next
- chrs(0) = (enc(0) << 2) Or (enc(1) >> 4)
- chrs(1) = (enc(1) And 15) << 4 Or (enc(2) >> 2)
- chrs(2) = (enc(2) And 3) << 6 Or enc(3)
- out.Append(Chr(chrs(0)))
- If enc(2) <> 64 Then out.Append(Chr(chrs(1)))
- If enc(3) <> 64 Then out.Append(Chr(chrs(2)))
- Loop While i < input.Length
- Return out.ToString
- End Function
- #End Region
- #Region "TIGO3FX"
- Public Function TIGO3FX_Encode(ByVal input As String) As String
- input = Uri.EscapeDataString(input)
- Dim key As String = "FrsxyzA8VtuvwDEqWZ/1+4klm67=cBCa5Ybdef0g2hij9nopMNO3GHIRSTJKLPQUX"
- Dim out As New System.Text.StringBuilder
- Dim i As Integer
- Do
- Dim enc(3) As Integer
- Dim chrs As Integer() = {0, 0, 0}
- For b As Integer = 0 To 2
- If i < input.Length Then chrs(b) = Asc(input(i))
- i += 1
- Next
- enc(0) = chrs(0) >> 2
- enc(1) = ((chrs(0) And 3) << 4) Or (chrs(1) >> 4)
- enc(2) = ((chrs(1) And 15) << 2) Or (chrs(2) >> 6)
- enc(3) = chrs(2) And 63
- If chrs(1) = 0 Then
- enc(2) = 64
- enc(3) = 64
- End If
- If chrs(2) = 0 Then
- enc(3) = 64
- End If
- For Each x As Integer In enc
- out.Append(key(x))
- Next
- Loop While i < input.Length
- Return out.ToString
- End Function
- Public Function TIGO3FX_Decode(ByVal input As String) As String
- Dim key As String = "FrsxyzA8VtuvwDEqWZ/1+4klm67=cBCa5Ybdef0g2hij9nopMNO3GHIRSTJKLPQUX"
- Dim out As New System.Text.StringBuilder
- Dim i As Integer
- Do
- Dim enc(3) As Integer
- Dim chrs() As Integer = {0, 0, 0}
- For b As Integer = 0 To 3
- enc(b) = key.IndexOf(input(i))
- i = i + 1
- Next
- chrs(0) = (enc(0) << 2) Or (enc(1) >> 4)
- chrs(1) = (enc(1) And 15) << 4 Or (enc(2) >> 2)
- chrs(2) = (enc(2) And 3) << 6 Or enc(3)
- out.Append(Chr(chrs(0)))
- If enc(2) <> 64 Then out.Append(Chr(chrs(1)))
- If enc(3) <> 64 Then out.Append(Chr(chrs(2)))
- Loop While i < input.Length
- Return out.ToString
- End Function
- #End Region
- #Region "FERON 74"
- Public Function FERON74_Encode(ByVal input As String) As String
- input = Uri.EscapeDataString(input)
- Dim key As String = "75XYTabcS/UVWdefADqr6RuvN8PBCsQtwx2KLyz+OM3Hk9ghi01ZFlmnjopE=GIJ4"
- Dim out As New System.Text.StringBuilder
- Dim i As Integer
- Do
- Dim enc(3) As Integer
- Dim chrs As Integer() = {0, 0, 0}
- For b As Integer = 0 To 2
- If i < input.Length Then chrs(b) = Asc(input(i))
- i += 1
- Next
- enc(0) = chrs(0) >> 2
- enc(1) = ((chrs(0) And 3) << 4) Or (chrs(1) >> 4)
- enc(2) = ((chrs(1) And 15) << 2) Or (chrs(2) >> 6)
- enc(3) = chrs(2) And 63
- If chrs(1) = 0 Then
- enc(2) = 64
- enc(3) = 64
- End If
- If chrs(2) = 0 Then
- enc(3) = 64
- End If
- For Each x As Integer In enc
- out.Append(key(x))
- Next
- Loop While i < input.Length
- Return out.ToString
- End Function
- Public Function FERON74_Decode(ByVal input As String) As String
- Dim key As String = "75XYTabcS/UVWdefADqr6RuvN8PBCsQtwx2KLyz+OM3Hk9ghi01ZFlmnjopE=GIJ4"
- Dim out As New System.Text.StringBuilder
- Dim i As Integer
- Do
- Dim enc(3) As Integer
- Dim chrs() As Integer = {0, 0, 0}
- For b As Integer = 0 To 3
- enc(b) = key.IndexOf(input(i))
- i = i + 1
- Next
- chrs(0) = (enc(0) << 2) Or (enc(1) >> 4)
- chrs(1) = (enc(1) And 15) << 4 Or (enc(2) >> 2)
- chrs(2) = (enc(2) And 3) << 6 Or enc(3)
- out.Append(Chr(chrs(0)))
- If enc(2) <> 64 Then out.Append(Chr(chrs(1)))
- If enc(3) <> 64 Then out.Append(Chr(chrs(2)))
- Loop While i < input.Length
- Return out.ToString
- End Function
- #End Region
- #Region "ZARA 128"
- Public Function ZARA128_Encode(ByVal input As String) As String
- Dim out As New System.Text.StringBuilder
- For Each c As Char In input
- Dim temp As Integer = Asc(c) + 312
- out.Append(temp.ToString & " ")
- Next
- Return out.ToString.Substring(0, out.Length - 1)
- End Function
- Public Function ZARA128_Decode(ByVal input As String) As String
- Dim out As New System.Text.StringBuilder
- Dim data As String() = Split(input, " ")
- For Each s As String In data
- out.Append(Chr(Asc(s) - 312))
- Next
- Return out.ToString
- End Function
- #End Region
- #Region "Base 64"
- Public Function BASE64_Encode(ByVal input As String) As String
- Return Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(input))
- End Function
- Public Function BASE64_Decode(ByVal input As String) As String
- Return System.Text.Encoding.ASCII.GetString(Convert.FromBase64String(input))
- End Function
- #End Region
- #Region "ARMON 64"
- Public Function ARMON64_Encrypt(ByVal message As String, Optional ByVal key As String = "ARMON64-CRYPO") As String
- Dim out As New System.Text.StringBuilder
- If key.Length < 3 Then Return message
- Dim intkey() As Byte = System.Text.Encoding.UTF8.GetBytes(key)
- Dim x As Integer
- Do While x < message.Length
- Dim hextemp As String = ""
- Dim y As String = ""
- If x > 0 Then y = "+"
- For i As Integer = x To Math.Round(key.Length / 2)
- If i < message.Length Then hextemp += Hex(Asc(message(i)))
- Next
- Dim thenum As Double = "&H" & hextemp
- If Information.IsNumeric(thenum) = False Then Return message
- For z As Integer = 0 To key.Length - 1
- Dim operation As Integer = z Mod 4
- Select Case operation
- Case 0
- thenum += intkey(z)
- Case 1
- thenum /= intkey(z)
- Case 2
- thenum -= intkey(z)
- Case 3
- thenum *= 0.01 * intkey(z)
- End Select
- Next
- out.Append(y & thenum)
- x += Math.Round(key.Length / 2)
- Loop
- Return out.ToString.Replace(",", ".")
- End Function
- Public Function ARMON64_Decrypt(ByVal message As String, Optional ByVal key As String = "ARMON64-CRYPO") As String
- Dim out As New System.Text.StringBuilder
- If key.Length < 6 Then Return message
- Dim intkey() As Byte = System.Text.Encoding.UTF8.GetBytes(key)
- message = message.Replace(".", ",")
- Dim oOutString As String() = Split(message, "+")
- For x As Integer = 0 To oOutString.Length - 1
- For z As Integer = key.Length - 1 To 0 Step -1
- Dim operation As Integer = z Mod 4
- Select Case operation
- Case 0
- oOutString(x) -= intkey(z)
- Case 1
- oOutString(x) *= intkey(z)
- Case 2
- oOutString(x) += intkey(z)
- Case 3
- oOutString(x) /= 0.01 * intkey(z)
- End Select
- Next
- oOutString(x) = Hex(Math.Round(Double.Parse(oOutString(x))))
- Next
- For i As Integer = 0 To Join(oOutString).Length - 1 Step +2
- out.Append(Chr(("&H" & Join(oOutString).Substring(i, 2))))
- Next
- Return out.ToString
- End Function
- #End Region
- #Region "AER 256"
- Public Function AER256_Encrypt(ByVal message As String, Optional ByVal key As String = "A256-CRYPO") As String
- Dim out As New System.Text.StringBuilder
- If key.Length < 10 Then Return message
- Dim intkey() As Byte = System.Text.Encoding.UTF8.GetBytes(key)
- Dim x As Integer
- Do While x < message.Length
- Dim hextemp As String = ""
- Dim y As String = ""
- If x > 0 Then y = ", "
- For i As Integer = x To Math.Round(key.Length / 2)
- If i < message.Length Then hextemp += Hex(Asc(message(i)))
- Next
- Dim thenum As Double = "&H" & hextemp
- If Information.IsNumeric(thenum) = False Then Return message
- For z As Integer = 0 To key.Length - 1
- Dim operation As Integer = z Mod 3
- Select Case operation
- Case 0
- thenum += intkey(z)
- Case 1
- thenum /= intkey(z)
- Case 2
- thenum -= intkey(z)
- Case 3
- thenum *= 0.02 * intkey(z)
- End Select
- Next
- Dim temp As String = thenum.ToString.Replace(",", ".")
- out.Append(y & temp)
- x += Math.Round(key.Length / 2)
- Loop
- Return out.ToString
- End Function
- Public Function AER256_Decrypt(ByVal message As String, Optional ByVal key As String = "A256-CRYPO") As String
- Dim out As New System.Text.StringBuilder
- If key.Length < 10 Then Return message
- Dim intkey() As Byte = System.Text.Encoding.UTF8.GetBytes(key)
- Dim oOutString As String() = Split(message, ", ")
- For i As Integer = 0 To oOutString.Length - 1
- oOutString(i) = oOutString(i).Replace(".", ",")
- Next
- For x As Integer = 0 To oOutString.Length - 1
- For z As Integer = key.Length - 1 To 0 Step -1
- Dim operation As Integer = z Mod 3
- Select Case operation
- Case 0
- oOutString(x) -= intkey(z)
- Case 1
- oOutString(x) *= intkey(z)
- Case 2
- oOutString(x) += intkey(z)
- Case 3
- oOutString(x) /= 0.02 * intkey(z)
- End Select
- Next
- oOutString(x) = Hex(Math.Round(Double.Parse(oOutString(x))))
- Next
- For i As Integer = 0 To Join(oOutString).Length - 1 Step +2
- out.Append(Chr(("&H" & Join(oOutString).Substring(i, 2))))
- Next
- Return out.ToString
- End Function
- #End Region
- #Region "EZIP 64"
- Public Function EZIP64_Encrypt(ByVal message As String, Optional ByVal key As String = "EZIP64-CRYPO") As String
- Dim out As New System.Text.StringBuilder
- If key.Length < 10 Then Return message
- Dim intkey() As Byte = System.Text.Encoding.UTF8.GetBytes(key)
- Dim x As Integer
- Do While x < message.Length
- Dim hextemp As String = ""
- Dim y As String = ""
- If x > 0 Then y = "/"
- For i As Integer = x To Math.Round(key.Length / 3)
- If i < message.Length Then hextemp += Hex(Asc(message(i)))
- Next
- Dim thenum As Double = "&H" & hextemp
- If Information.IsNumeric(thenum) = False Then Return message
- For z As Integer = 0 To key.Length - 1
- Dim operation As Integer = z Mod 4
- Select Case operation
- Case 0
- thenum += intkey(z)
- Case 1
- thenum /= intkey(z)
- Case 2
- thenum -= intkey(z)
- Case 3
- thenum *= 0.02 * intkey(z)
- End Select
- Next
- Dim temp As String = thenum.ToString.Replace(",", ".")
- out.Append(y & temp)
- x += Math.Round(key.Length / 3)
- Loop
- Return out.ToString
- End Function
- Public Function EZIP64_Decrypt(ByVal message As String, Optional ByVal key As String = "EZIP64-CRYPO") As String
- Dim out As New System.Text.StringBuilder
- If key.Length < 10 Then Return message
- Dim intkey() As Byte = System.Text.Encoding.UTF8.GetBytes(key)
- Dim oOutString As String() = Split(message, "/")
- For i As Integer = 0 To oOutString.Length - 1
- oOutString(i) = oOutString(i).Replace(".", ",")
- Next
- For x As Integer = 0 To oOutString.Length - 1
- For z As Integer = key.Length - 1 To 0 Step -1
- Dim operation As Integer = z Mod 4
- Select Case operation
- Case 0
- oOutString(x) -= intkey(z)
- Case 1
- oOutString(x) *= intkey(z)
- Case 2
- oOutString(x) += intkey(z)
- Case 3
- oOutString(x) /= 0.02 * intkey(z)
- End Select
- Next
- oOutString(x) = Hex(Math.Round(Double.Parse(oOutString(x))))
- Next
- For i As Integer = 0 To Join(oOutString).Length - 1 Step +2
- out.Append(Chr(("&H" & Join(oOutString).Substring(i, 2))))
- Dim j As String = out.ToString
- Next
- Return out.ToString
- End Function
- #End Region
- #Region "OKTO3"
- Public Function OKTO3_Encrypt(ByVal message As String, Optional ByVal key As String = "PASS:OKTO3-CRYPO") As String
- Dim out As New System.Text.StringBuilder
- If key.Length < 10 Then Return message
- Dim intkey() As Byte = System.Text.Encoding.UTF8.GetBytes(key)
- Dim x As Integer
- Do While x < message.Length
- Dim hextemp As String = ""
- Dim y As String = ""
- If x > 0 Then y = ", "
- For i As Integer = x To Math.Round(key.Length / 6)
- If i < message.Length Then hextemp += Hex(Asc(message(i)))
- Next
- Dim thenum As Double = "&H" & hextemp
- If Information.IsNumeric(thenum) = False Then Return message
- For z As Integer = 0 To key.Length - 1
- Dim operation As Integer = z Mod 3
- Select Case operation
- Case 0
- thenum += intkey(z)
- Case 1
- thenum /= intkey(z)
- Case 2
- thenum -= intkey(z)
- Case 3
- thenum *= 500.005 * intkey(z)
- End Select
- Next
- Dim temp As String = thenum.ToString.Replace(",", ".")
- out.Append(y & temp)
- x += Math.Round(key.Length / 6)
- Loop
- Return out.ToString
- End Function
- Public Function OKTO3_Decrypt(ByVal message As String, Optional ByVal key As String = "PASS:OKTO3-CRYPO") As String
- Dim out As New System.Text.StringBuilder
- If key.Length < 10 Then Return message
- Dim intkey() As Byte = System.Text.Encoding.UTF8.GetBytes(key)
- Dim oOutString As String() = Split(message, ", ")
- For i As Integer = 0 To oOutString.Length - 1
- oOutString(i) = oOutString(i).Replace(".", ",")
- Next
- For x As Integer = 0 To oOutString.Length - 1
- For z As Integer = key.Length - 1 To 0 Step -1
- Dim operation As Integer = z Mod 3
- Select Case operation
- Case 0
- oOutString(x) -= intkey(z)
- Case 1
- oOutString(x) *= intkey(z)
- Case 2
- oOutString(x) += intkey(z)
- Case 3
- oOutString(x) /= 0.02 * intkey(z)
- End Select
- Next
- oOutString(x) = Hex(Math.Round(Double.Parse(oOutString(x))))
- Next
- For i As Integer = 0 To Join(oOutString).Length - 1 Step +2
- out.Append(Chr(("&H" & Join(oOutString).Substring(i, 2))))
- Next
- Return out.ToString
- End Function
- #End Region
- #Region "Rc4"
- Public Shared Function rc4(ByVal message As String, ByVal password As String) As String
- Dim i As Integer = 0
- Dim j As Integer = 0
- Dim cipher As New StringBuilder
- Dim returnCipher As String = String.Empty
- Dim sbox As Integer() = New Integer(256) {}
- Dim key As Integer() = New Integer(256) {}
- Dim intLength As Integer = password.Length
- Dim a As Integer = 0
- While a <= 255
- Dim ctmp As Char = (password.Substring((a Mod intLength), 1).ToCharArray()(0))
- key(a) = Microsoft.VisualBasic.Strings.Asc(ctmp)
- sbox(a) = a
- System.Math.Max(System.Threading.Interlocked.Increment(a), a - 1)
- End While
- Dim x As Integer = 0
- Dim b As Integer = 0
- While b <= 255
- x = (x + sbox(b) + key(b)) Mod 256
- Dim tempSwap As Integer = sbox(b)
- sbox(b) = sbox(x)
- sbox(x) = tempSwap
- System.Math.Max(System.Threading.Interlocked.Increment(b), b - 1)
- End While
- a = 1
- While a <= message.Length
- Dim itmp As Integer = 0
- i = (i + 1) Mod 256
- j = (j + sbox(i)) Mod 256
- itmp = sbox(i)
- sbox(i) = sbox(j)
- sbox(j) = itmp
- Dim k As Integer = sbox((sbox(i) + sbox(j)) Mod 256)
- Dim ctmp As Char = message.Substring(a - 1, 1).ToCharArray()(0)
- itmp = Asc(ctmp)
- Dim cipherby As Integer = itmp Xor k
- cipher.Append(Chr(cipherby))
- System.Math.Max(System.Threading.Interlocked.Increment(a), a - 1)
- End While
- returnCipher = cipher.ToString
- cipher.Length = 0
- Return returnCipher
- End Function
- #End Region
- #Region "Hashs"
- Public Function MD5Hash(ByVal input As String) As String
- Dim MD5 As New System.Security.Cryptography.MD5CryptoServiceProvider
- Dim Data As Byte()
- Dim Result As Byte()
- Dim Res As String = ""
- Dim Tmp As String = ""
- Data = System.Text.Encoding.ASCII.GetBytes(input)
- Result = MD5.ComputeHash(Data)
- For i As Integer = 0 To Result.Length - 1
- Tmp = Hex(Result(i))
- If Len(Tmp) = 1 Then Tmp = "0" & Tmp
- Res += Tmp
- Next
- Return Res
- End Function
- Public Function RIPEMD160Hash(ByVal input As String) As String
- Dim RIPEMD160 As New System.Security.Cryptography.RIPEMD160Managed
- Dim Data As Byte()
- Dim Result As Byte()
- Dim Res As String = ""
- Dim Tmp As String = ""
- Data = System.Text.Encoding.ASCII.GetBytes(input)
- Result = RIPEMD160.ComputeHash(Data)
- For i As Integer = 0 To Result.Length - 1
- Tmp = Hex(Result(i))
- If Len(Tmp) = 1 Then Tmp = "0" & Tmp
- Res += Tmp
- Next
- Return Res
- End Function
- Public Function SHA1Hash(ByVal input As String) As String
- Dim SHA1 As New System.Security.Cryptography.SHA1CryptoServiceProvider
- Dim Data As Byte()
- Dim Result As Byte()
- Dim Res As String = ""
- Dim Tmp As String = ""
- Data = System.Text.Encoding.ASCII.GetBytes(input)
- Result = SHA1.ComputeHash(Data)
- For i As Integer = 0 To Result.Length - 1
- Tmp = Hex(Result(i))
- If Len(Tmp) = 1 Then Tmp = "0" & Tmp
- Res += Tmp
- Next
- Return Res
- End Function
- Public Function SHA256Hash(ByVal input As String) As String
- Dim SHA256 As New System.Security.Cryptography.SHA256Managed
- Dim Data As Byte()
- Dim Result As Byte()
- Dim Res As String = ""
- Dim Tmp As String = ""
- Data = System.Text.Encoding.ASCII.GetBytes(input)
- Result = SHA256.ComputeHash(Data)
- For i As Integer = 0 To Result.Length - 1
- Tmp = Hex(Result(i))
- If Len(Tmp) = 1 Then Tmp = "0" & Tmp
- Res += Tmp
- Next
- Return Res
- End Function
- Public Function SHA348Hash(ByVal input As String) As String
- Dim SHA348 As New System.Security.Cryptography.SHA384Managed
- Dim Data As Byte()
- Dim Result As Byte()
- Dim Res As String = ""
- Dim Tmp As String = ""
- Data = System.Text.Encoding.ASCII.GetBytes(input)
- Result = SHA348.ComputeHash(Data)
- For i As Integer = 0 To Result.Length - 1
- Tmp = Hex(Result(i))
- If Len(Tmp) = 1 Then Tmp = "0" & Tmp
- Res += Tmp
- Next
- Return Res
- End Function
- Public Function SHA512Hash(ByVal input As String) As String
- Dim SHA512 As New System.Security.Cryptography.SHA512Managed
- Dim Data As Byte()
- Dim Result As Byte()
- Dim Res As String = ""
- Dim Tmp As String = ""
- Data = System.Text.Encoding.ASCII.GetBytes(input)
- Result = SHA512.ComputeHash(Data)
- For i As Integer = 0 To Result.Length - 1
- Tmp = Hex(Result(i))
- If Len(Tmp) = 1 Then Tmp = "0" & Tmp
- Res += Tmp
- Next
- Return Res
- End Function
- #End Region
- #Region "Chiffre de César"
- Public Function Encrypt(ByVal PlainText As String, ByVal Key As Integer) As String
- Dim PlainChar() As Char = PlainText.ToCharArray()
- Dim Ascii(PlainChar.Length) As Integer
- For Count As Integer = 0 To PlainChar.Length - 1
- Ascii(Count) = Asc(PlainChar(Count))
- If Ascii(Count) >= 65 And Ascii(Count) <= 90 Then
- Ascii(Count) = ((Ascii(Count) - 65 + Key) Mod 26) + 65
- ElseIf Ascii(Count) >= 97 And Ascii(Count) <= 122 Then
- Ascii(Count) = ((Ascii(Count) - 97 + Key) Mod 26) + 97
- End If
- PlainChar(Count) = Chr(Ascii(Count))
- Next
- Return PlainChar
- End Function
- Public Function Decrypt(ByVal CipherText As String, ByVal Key As Integer) As String
- Dim CipherChar() As Char = CipherText.ToCharArray()
- Dim Ascii(CipherChar.Length) As Integer
- For Count As Integer = 0 To CipherChar.Length - 1
- Ascii(Count) = Asc(CipherChar(Count))
- If Ascii(Count) >= 65 And Ascii(Count) <= 90 Then
- Ascii(Count) = ((Ascii(Count) - 65 - (Key Mod 26) + 26)) Mod 26 + 65
- ElseIf Ascii(Count) >= 97 And Ascii(Count) <= 122 Then
- Ascii(Count) = (((Ascii(Count) - 97 - (Key Mod 26) + 26)) Mod 26) + 97
- End If
- CipherChar(Count) = Chr(Ascii(Count))
- Next
- Return CipherChar
- End Function
- #End Region
- #Region "ROT13"
- Public Function ROT13(ByVal input As String) As String
- Dim out As New System.Text.StringBuilder
- For i As Integer = 0 To input.Length - 1
- out.Append(Chr(Asc(input(i)) Xor 13))
- Next
- Return out.ToString
- End Function
- #End Region
- #Region "RSA"
- Public Function RSA_Encrypt(ByVal Input As String) As String
- Dim cp As New Security.Cryptography.CspParameters
- cp.Flags = Security.Cryptography.CspProviderFlags.UseMachineKeyStore
- cp.KeyContainerName = "Keys"
- Dim RSA As New Security.Cryptography.RSACryptoServiceProvider(cp)
- Dim buffer As Byte() = System.Text.Encoding.UTF8.GetBytes(Input)
- Dim encrypted As Byte() = RSA.Encrypt(buffer, True)
- Return Convert.ToBase64String(encrypted)
- End Function
- Public Function RSA_Decrypt(ByVal Input As String) As String
- Dim cp As New Security.Cryptography.CspParameters
- cp.Flags = Security.Cryptography.CspProviderFlags.UseMachineKeyStore
- cp.KeyContainerName = "Keys"
- Dim RSA As New Security.Cryptography.RSACryptoServiceProvider(cp)
- Dim buffer As Byte() = Convert.FromBase64String(Input)
- Dim decrypted As Byte() = RSA.Decrypt(buffer, True)
- Return System.Text.Encoding.UTF8.GetString(decrypted)
- End Function
- #End Region
- #Region "XOR"
- #Region "Normale"
- Public Function XOR_Encrypt(ByVal Input As String, ByVal pass As String) As String
- Dim out As New System.Text.StringBuilder
- Dim u As Integer
- For i As Integer = 0 To Input.Length - 1
- Dim tmp As String = Hex(Asc(Input(i)) Xor Asc(pass(u)))
- If tmp.Length = 1 Then tmp = "0" & tmp
- out.Append(tmp)
- If u = pass.Length - 1 Then u = 0 Else u = u + 1
- Next
- Return out.ToString
- End Function
- Public Function XOR_Decrypt(ByVal Input As String, ByVal pass As String) As String
- Dim out As New System.Text.StringBuilder
- Dim u As Integer
- For i As Integer = 0 To Input.Length - 1 Step +2
- Dim tmp As String = Chr(("&H" & Input.Substring(i, 2)) Xor Asc(pass(u)))
- out.Append(tmp)
- If u = pass.Length - 1 Then u = 0 Else u = u + 1
- Next
- Return out.ToString
- End Function
- #End Region
- #Region "Personnalisée"
- Public Function CustomXOR_Encrypt(ByVal Input As String, ByVal pass As String) As String
- Dim out As New System.Text.StringBuilder
- Dim Hash As New System.Security.Cryptography.MD5CryptoServiceProvider
- Dim XorHash As Byte() = Hash.ComputeHash(System.Text.Encoding.ASCII.GetBytes(pass))
- Dim u As Integer
- For i As Integer = 0 To Input.Length - 1
- Dim tmp As String = Hex(Asc(Input(i)) Xor XorHash(u))
- If tmp.Length = 1 Then tmp = "0" & tmp
- out.Append(tmp)
- If u = pass.Length - 1 Then u = 0 Else u = u + 1
- Next
- Return out.ToString
- End Function
- Public Function CustomXOR_Decrypt(ByVal Input As String, ByVal pass As String) As String
- Dim out As New System.Text.StringBuilder
- Dim Hash As New System.Security.Cryptography.MD5CryptoServiceProvider
- Dim XorHash As Byte() = Hash.ComputeHash(System.Text.Encoding.ASCII.GetBytes(pass))
- Dim u As Integer
- For i As Integer = 0 To Input.Length - 1 Step +2
- Dim tmp As String = Chr(("&H" & Input.Substring(i, 2)) Xor XorHash(u))
- out.Append(tmp)
- If u = pass.Length - 1 Then u = 0 Else u = u + 1
- Next
- Return out.ToString
- End Function
- #End Region
- #End Region
- #Region "Rc2"
- Public Function RC2_Encrypt(ByVal input As String, ByVal pass As String) As String
- Dim RC2 As New System.Security.Cryptography.RC2CryptoServiceProvider
- Dim Hash_RC2 As New System.Security.Cryptography.MD5CryptoServiceProvider
- Dim encrypted As String = ""
- Try
- Dim hash() As Byte = Hash_RC2.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
- RC2.Key = hash
- RC2.Mode = Security.Cryptography.CipherMode.ECB
- Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = RC2.CreateEncryptor
- Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(input)
- encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
- Return encrypted
- Catch ex As Exception
- End Try
- End Function
- Public Function RC2_Decrypt(ByVal input As String, ByVal pass As String) As String
- Dim RC2 As New System.Security.Cryptography.RC2CryptoServiceProvider
- Dim Hash_RC2 As New System.Security.Cryptography.MD5CryptoServiceProvider
- Dim decrypted As String = ""
- Try
- Dim hash() As Byte = Hash_RC2.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
- RC2.Key = hash
- RC2.Mode = Security.Cryptography.CipherMode.ECB
- Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = RC2.CreateDecryptor
- Dim Buffer As Byte() = Convert.FromBase64String(input)
- decrypted = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
- Return decrypted
- Catch ex As Exception
- End Try
- End Function
- #End Region
- #Region "DES"
- Public Function DES_Encrypt(ByVal input As String, ByVal pass As String) As String
- Dim DES As New System.Security.Cryptography.DESCryptoServiceProvider
- Dim Hash_DES As New System.Security.Cryptography.MD5CryptoServiceProvider
- Dim encrypted As String = ""
- Try
- Dim hash(7) As Byte
- Dim temp As Byte() = Hash_DES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
- Array.Copy(temp, 0, hash, 0, 8)
- DES.Key = hash
- DES.Mode = Security.Cryptography.CipherMode.ECB
- Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = DES.CreateEncryptor
- Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(input)
- encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
- Return encrypted
- Catch ex As Exception
- End Try
- End Function
- Public Function DES_Decrypt(ByVal input As String, ByVal pass As String) As String
- Dim DES As New System.Security.Cryptography.DESCryptoServiceProvider
- Dim Hash_DES As New System.Security.Cryptography.MD5CryptoServiceProvider
- Dim decrypted As String = ""
- Try
- Dim hash(7) As Byte
- Dim temp As Byte() = Hash_DES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
- Array.Copy(temp, 0, hash, 0, 8)
- DES.Key = hash
- DES.Mode = Security.Cryptography.CipherMode.ECB
- Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = DES.CreateDecryptor
- Dim Buffer As Byte() = Convert.FromBase64String(input)
- decrypted = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
- Return decrypted
- Catch ex As Exception
- End Try
- End Function
- #End Region
- #Region "Triple DES"
- Public Function TripleDES_Encrypt(ByVal input As String, ByVal pass As String) As String
- Dim TripleDES As New System.Security.Cryptography.TripleDESCryptoServiceProvider
- Dim Hash_TripleDES As New System.Security.Cryptography.MD5CryptoServiceProvider
- Dim encrypted As String = ""
- Try
- Dim hash(23) As Byte
- Dim temp As Byte() = Hash_TripleDES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
- Array.Copy(temp, 0, hash, 0, 16)
- Array.Copy(temp, 0, hash, 15, 8)
- TripleDES.Key = hash
- TripleDES.Mode = Security.Cryptography.CipherMode.ECB
- Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = TripleDES.CreateEncryptor
- Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(input)
- encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
- Return encrypted
- Catch ex As Exception
- End Try
- End Function
- Public Function TripleDES_Decrypt(ByVal input As String, ByVal pass As String) As String
- Dim TripleDES As New System.Security.Cryptography.TripleDESCryptoServiceProvider
- Dim Hash_TripleDES As New System.Security.Cryptography.MD5CryptoServiceProvider
- Dim decrypted As String = ""
- Try
- Dim hash(23) As Byte
- Dim temp As Byte() = Hash_TripleDES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
- Array.Copy(temp, 0, hash, 0, 16)
- Array.Copy(temp, 0, hash, 15, 8)
- TripleDES.Key = hash
- TripleDES.Mode = Security.Cryptography.CipherMode.ECB
- Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = TripleDES.CreateDecryptor
- Dim Buffer As Byte() = Convert.FromBase64String(input)
- decrypted = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
- Return decrypted
- Catch ex As Exception
- End Try
- End Function
- #End Region
- #Region "AES"
- Public Function AES_Encrypt(ByVal input As String, ByVal pass As String) As String
- Dim AES As New System.Security.Cryptography.RijndaelManaged
- Dim Hash_AES As New System.Security.Cryptography.MD5CryptoServiceProvider
- Dim encrypted As String = ""
- Try
- Dim hash(31) As Byte
- Dim temp As Byte() = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
- Array.Copy(temp, 0, hash, 0, 16)
- Array.Copy(temp, 0, hash, 15, 16)
- AES.Key = hash
- AES.Mode = Security.Cryptography.CipherMode.ECB
- Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = AES.CreateEncryptor
- Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(input)
- encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
- Return encrypted
- Catch ex As Exception
- End Try
- End Function
- Public Function AES_Decrypt(ByVal input As String, ByVal pass As String) As String
- Dim AES As New System.Security.Cryptography.RijndaelManaged
- Dim Hash_AES As New System.Security.Cryptography.MD5CryptoServiceProvider
- Dim decrypted As String = ""
- Try
- Dim hash(31) As Byte
- Dim temp As Byte() = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
- Array.Copy(temp, 0, hash, 0, 16)
- Array.Copy(temp, 0, hash, 15, 16)
- AES.Key = hash
- AES.Mode = Security.Cryptography.CipherMode.ECB
- Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = AES.CreateDecryptor
- Dim Buffer As Byte() = Convert.FromBase64String(input)
- decrypted = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
- Return decrypted
- Catch ex As Exception
- End Try
- End Function
- #End Region
- #Region "Chaîne renversée"
- Public Function ReverseString(ByRef strToReverse As String) As String
- Dim result As String = ""
- For i As Integer = 0 To strToReverse.Length - 1
- result += strToReverse(strToReverse.Length - 1 - i)
- Next
- Return result
- End Function
- #End Region
- #Region "Rijndael"
- Public Shared Function RijndaelDecrypt(ByVal UDecryptU As String, ByVal UKeyU As String)
- Dim XoAesProviderX As New RijndaelManaged
- Dim XbtCipherX() As Byte
- Dim XbtSaltX() As Byte = New Byte() {1, 2, 3, 4, 5, 6, 7, 8}
- Dim XoKeyGeneratorX As New Rfc2898DeriveBytes(UKeyU, XbtSaltX)
- XoAesProviderX.Key = XoKeyGeneratorX.GetBytes(XoAesProviderX.Key.Length)
- XoAesProviderX.IV = XoKeyGeneratorX.GetBytes(XoAesProviderX.IV.Length)
- Dim XmsX As New IO.MemoryStream
- Dim XcsX As New CryptoStream(XmsX, XoAesProviderX.CreateDecryptor(), _
- CryptoStreamMode.Write)
- Try
- XbtCipherX = Convert.FromBase64String(UDecryptU)
- XcsX.Write(XbtCipherX, 0, XbtCipherX.Length)
- XcsX.Close()
- UDecryptU = System.Text.Encoding.UTF8.GetString(XmsX.ToArray)
- Catch
- End Try
- Return UDecryptU
- End Function
- Public Shared Function Rijndaelcrypt(ByVal File As String, ByVal Key As String)
- Dim oAesProvider As New RijndaelManaged
- Dim btClear() As Byte
- Dim btSalt() As Byte = New Byte() {1, 2, 3, 4, 5, 6, 7, 8}
- Dim oKeyGenerator As New Rfc2898DeriveBytes(Key, btSalt)
- oAesProvider.Key = oKeyGenerator.GetBytes(oAesProvider.Key.Length)
- oAesProvider.IV = oKeyGenerator.GetBytes(oAesProvider.IV.Length)
- Dim ms As New IO.MemoryStream
- Dim cs As New CryptoStream(ms, _
- oAesProvider.CreateEncryptor(), _
- CryptoStreamMode.Write)
- btClear = System.Text.Encoding.UTF8.GetBytes(File)
- cs.Write(btClear, 0, btClear.Length)
- cs.Close()
- File = Convert.ToBase64String(ms.ToArray)
- Return File
- End Function
- #End Region
- #Region "Hexadécimal"
- Public Function String2Hex(ByVal input As String) As String
- Dim out As New System.Text.StringBuilder
- For Each c As String In input
- Dim temp As String = Hex(Asc(c))
- out.Append(temp & " ")
- Next
- Return out.ToString.Substring(0, out.Length - 1)
- End Function
- Public Function Hex2String(ByVal input As String) As String
- Dim out As New System.Text.StringBuilder
- Dim data As String() = Split(input, " ")
- For Each s As String In data
- out.Append(Chr("&H" & s))
- Next
- Return out.ToString
- End Function
- #End Region
- #Region "Binaire"
- Private Function ConvertToAscii(ByVal str As String) As String
- Dim chars As String = Regex.Replace(str, "[^01]", "")
- Dim arr((chars.Length / 8) - 1) As Byte
- For i As Integer = 0 To arr.Length - 1
- arr(i) = Convert.ToByte(chars.Substring(i * 8, 8), 2)
- Next
- Return ASCIIEncoding.ASCII.GetString(arr)
- End Function
- Private Function ConvertToBinary(ByVal str As String) As String
- Dim converted As New StringBuilder
- For Each b As Byte In ASCIIEncoding.ASCII.GetBytes(str)
- converted.Append(Convert.ToString(b, 2).PadLeft(8, "0"))
- Next
- Return converted.ToString()
- End Function
- #End Region
- End Class
Add Comment
Please, Sign In to add comment