SHARE
TWEET

Fonctions de cryptage VB.NET (http://www.leblogduhacker.fr)

a guest Oct 2nd, 2013 713 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Text
  2. Imports System.Text.RegularExpressions
  3. Imports System.Security.Cryptography
  4.  
  5. 'Fonctions de cryptage (http://www.leblogduhacker.fr)
  6.  
  7. Public Class Cryptage
  8. #Region "Atom 128"
  9.     Public Function Atom128_Encode(ByVal input As String) As String
  10.         input = Uri.EscapeDataString(input)
  11.         Dim key As String = "/128GhIoPQROSTeUbADfgHijKLM+n0pFWXY456xyzB7=39VaqrstJklmNuZvwcdEC"
  12.         Dim out As New System.Text.StringBuilder
  13.         Dim i As Integer
  14.         Do
  15.             Dim enc(3) As Integer
  16.             Dim chrs As Integer() = {0, 0, 0}
  17.             For b As Integer = 0 To 2
  18.                 If i < input.Length Then chrs(b) = Asc(input(i))
  19.                 i += 1
  20.             Next
  21.             enc(0) = chrs(0) >> 2
  22.             enc(1) = ((chrs(0) And 3) << 4) Or (chrs(1) >> 4)
  23.             enc(2) = ((chrs(1) And 15) << 2) Or (chrs(2) >> 6)
  24.             enc(3) = chrs(2) And 63
  25.             If chrs(1) = 0 Then
  26.                 enc(2) = 64
  27.                 enc(3) = 64
  28.             End If
  29.             If chrs(2) = 0 Then
  30.                 enc(3) = 64
  31.             End If
  32.             For Each x As Integer In enc
  33.                 out.Append(key(x))
  34.             Next
  35.         Loop While i < input.Length
  36.         Return out.ToString
  37.     End Function
  38.     Public Function Atom128_Decode(ByVal input As String) As String
  39.         Dim key As String = "/128GhIoPQROSTeUbADfgHijKLM+n0pFWXY456xyzB7=39VaqrstJklmNuZvwcdEC"
  40.         Dim out As New System.Text.StringBuilder
  41.         Dim i As Integer
  42.         Do
  43.             Dim enc(3) As Integer
  44.             Dim chrs() As Integer = {0, 0, 0}
  45.             For b As Integer = 0 To 3
  46.                 enc(b) = key.IndexOf(input(i))
  47.                 i = i + 1
  48.             Next
  49.             chrs(0) = (enc(0) << 2) Or (enc(1) >> 4)
  50.             chrs(1) = (enc(1) And 15) << 4 Or (enc(2) >> 2)
  51.             chrs(2) = (enc(2) And 3) << 6 Or enc(3)
  52.             out.Append(Chr(chrs(0)))
  53.             If enc(2) <> 64 Then out.Append(Chr(chrs(1)))
  54.             If enc(3) <> 64 Then out.Append(Chr(chrs(2)))
  55.         Loop While i < input.Length
  56.         Return out.ToString
  57.     End Function
  58. #End Region
  59. #Region "HAZZ 15"
  60.     Public Function HAZZ15_Encode(ByVal input As String) As String
  61.         input = Uri.EscapeDataString(input)
  62.         Dim key As String = "HNO4klm6ij9n+J2hyf0gzA8uvwDEq3X1Q7ZKeFrWcVTts/MRGYbdxSo=ILaUpPBC5"
  63.         Dim out As New System.Text.StringBuilder
  64.         Dim i As Integer
  65.         Do
  66.             Dim enc(3) As Integer
  67.             Dim chrs As Integer() = {0, 0, 0}
  68.             For b As Integer = 0 To 2
  69.                 If i < input.Length Then chrs(b) = Asc(input(i))
  70.                 i += 1
  71.             Next
  72.             enc(0) = chrs(0) >> 2
  73.             enc(1) = ((chrs(0) And 3) << 4) Or (chrs(1) >> 4)
  74.             enc(2) = ((chrs(1) And 15) << 2) Or (chrs(2) >> 6)
  75.             enc(3) = chrs(2) And 63
  76.             If chrs(1) = 0 Then
  77.                 enc(2) = 64
  78.                 enc(3) = 64
  79.             End If
  80.             If chrs(2) = 0 Then
  81.                 enc(3) = 64
  82.             End If
  83.             For Each x As Integer In enc
  84.                 out.Append(key(x))
  85.             Next
  86.         Loop While i < input.Length
  87.         Return out.ToString
  88.     End Function
  89.     Public Function HAZZ15_Decode(ByVal input As String) As String
  90.         Dim key As String = "HNO4klm6ij9n+J2hyf0gzA8uvwDEq3X1Q7ZKeFrWcVTts/MRGYbdxSo=ILaUpPBC5"
  91.         Dim out As New System.Text.StringBuilder
  92.         Dim i As Integer
  93.         Do
  94.             Dim enc(3) As Integer
  95.             Dim chrs() As Integer = {0, 0, 0}
  96.             For b As Integer = 0 To 3
  97.                 enc(b) = key.IndexOf(input(i))
  98.                 i = i + 1
  99.             Next
  100.             chrs(0) = (enc(0) << 2) Or (enc(1) >> 4)
  101.             chrs(1) = (enc(1) And 15) << 4 Or (enc(2) >> 2)
  102.             chrs(2) = (enc(2) And 3) << 6 Or enc(3)
  103.             out.Append(Chr(chrs(0)))
  104.             If enc(2) <> 64 Then out.Append(Chr(chrs(1)))
  105.             If enc(3) <> 64 Then out.Append(Chr(chrs(2)))
  106.         Loop While i < input.Length
  107.         Return out.ToString
  108.     End Function
  109. #End Region
  110. #Region "GILA 7"
  111.     Public Function GILA7_Encode(ByVal input As String) As String
  112.         input = Uri.EscapeDataString(input)
  113.         Dim key As String = "7ZSTJK+W=cVtBCasyf0gzA8uvwDEq3XH/1RMNOILPQU4klm65YbdeFrx2hij9nopG"
  114.         Dim out As New System.Text.StringBuilder
  115.         Dim i As Integer
  116.         Do
  117.             Dim enc(3) As Integer
  118.             Dim chrs As Integer() = {0, 0, 0}
  119.             For b As Integer = 0 To 2
  120.                 If i < input.Length Then chrs(b) = Asc(input(i))
  121.                 i += 1
  122.             Next
  123.             enc(0) = chrs(0) >> 2
  124.             enc(1) = ((chrs(0) And 3) << 4) Or (chrs(1) >> 4)
  125.             enc(2) = ((chrs(1) And 15) << 2) Or (chrs(2) >> 6)
  126.             enc(3) = chrs(2) And 63
  127.             If chrs(1) = 0 Then
  128.                 enc(2) = 64
  129.                 enc(3) = 64
  130.             End If
  131.             If chrs(2) = 0 Then
  132.                 enc(3) = 64
  133.             End If
  134.             For Each x As Integer In enc
  135.                 out.Append(key(x))
  136.             Next
  137.         Loop While i < input.Length
  138.         Return out.ToString
  139.     End Function
  140.     Public Function GILA7_Decode(ByVal input As String) As String
  141.         Dim key As String = "7ZSTJK+W=cVtBCasyf0gzA8uvwDEq3XH/1RMNOILPQU4klm65YbdeFrx2hij9nopG"
  142.         Dim out As New System.Text.StringBuilder
  143.         Dim i As Integer
  144.         Do
  145.             Dim enc(3) As Integer
  146.             Dim chrs() As Integer = {0, 0, 0}
  147.             For b As Integer = 0 To 3
  148.                 enc(b) = key.IndexOf(input(i))
  149.                 i = i + 1
  150.             Next
  151.             chrs(0) = (enc(0) << 2) Or (enc(1) >> 4)
  152.             chrs(1) = (enc(1) And 15) << 4 Or (enc(2) >> 2)
  153.             chrs(2) = (enc(2) And 3) << 6 Or enc(3)
  154.             out.Append(Chr(chrs(0)))
  155.             If enc(2) <> 64 Then out.Append(Chr(chrs(1)))
  156.             If enc(3) <> 64 Then out.Append(Chr(chrs(2)))
  157.         Loop While i < input.Length
  158.         Return out.ToString
  159.     End Function
  160. #End Region
  161. #Region "ESAB 46"
  162.     Public Function ESAB46_Encode(ByVal input As String) As String
  163.         input = Uri.EscapeDataString(input)
  164.         Dim key As String = "ABCDqrs456tuvNOPwxyz012KLM3789=+QRSTUVWXYZabcdefghijklmnopEFGHIJ/"
  165.         Dim out As New System.Text.StringBuilder
  166.         Dim i As Integer
  167.         Do
  168.             Dim enc(3) As Integer
  169.             Dim chrs As Integer() = {0, 0, 0}
  170.             For b As Integer = 0 To 2
  171.                 If i < input.Length Then chrs(b) = Asc(input(i))
  172.                 i += 1
  173.             Next
  174.             enc(0) = chrs(0) >> 2
  175.             enc(1) = ((chrs(0) And 3) << 4) Or (chrs(1) >> 4)
  176.             enc(2) = ((chrs(1) And 15) << 2) Or (chrs(2) >> 6)
  177.             enc(3) = chrs(2) And 63
  178.             If chrs(1) = 0 Then
  179.                 enc(2) = 64
  180.                 enc(3) = 64
  181.             End If
  182.             If chrs(2) = 0 Then
  183.                 enc(3) = 64
  184.             End If
  185.             For Each x As Integer In enc
  186.                 out.Append(key(x))
  187.             Next
  188.         Loop While i < input.Length
  189.         Return out.ToString
  190.     End Function
  191.     Public Function ESAB46_Decode(ByVal input As String) As String
  192.         Dim key As String = "ABCDqrs456tuvNOPwxyz012KLM3789=+QRSTUVWXYZabcdefghijklmnopEFGHIJ/"
  193.         Dim out As New System.Text.StringBuilder
  194.         Dim i As Integer
  195.         Do
  196.             Dim enc(3) As Integer
  197.             Dim chrs() As Integer = {0, 0, 0}
  198.             For b As Integer = 0 To 3
  199.                 enc(b) = key.IndexOf(input(i))
  200.                 i = i + 1
  201.             Next
  202.             chrs(0) = (enc(0) << 2) Or (enc(1) >> 4)
  203.             chrs(1) = (enc(1) And 15) << 4 Or (enc(2) >> 2)
  204.             chrs(2) = (enc(2) And 3) << 6 Or enc(3)
  205.             out.Append(Chr(chrs(0)))
  206.             If enc(2) <> 64 Then out.Append(Chr(chrs(1)))
  207.             If enc(3) <> 64 Then out.Append(Chr(chrs(2)))
  208.         Loop While i < input.Length
  209.         Return out.ToString
  210.     End Function
  211. #End Region
  212. #Region "Megan 35"
  213.     Public Function MEGAN35_Encode(ByVal input As String) As String
  214.         input = Uri.EscapeDataString(input)
  215.         Dim key As String = "3GHIJKLMNOPQRSTUb=cdefghijklmnopWXYZ/12+406789VaqrstuvwxyzABCDEF5"
  216.         Dim out As New System.Text.StringBuilder
  217.         Dim i As Integer
  218.         Do
  219.             Dim enc(3) As Integer
  220.             Dim chrs As Integer() = {0, 0, 0}
  221.             For b As Integer = 0 To 2
  222.                 If i < input.Length Then chrs(b) = Asc(input(i))
  223.                 i += 1
  224.             Next
  225.             enc(0) = chrs(0) >> 2
  226.             enc(1) = ((chrs(0) And 3) << 4) Or (chrs(1) >> 4)
  227.             enc(2) = ((chrs(1) And 15) << 2) Or (chrs(2) >> 6)
  228.             enc(3) = chrs(2) And 63
  229.             If chrs(1) = 0 Then
  230.                 enc(2) = 64
  231.                 enc(3) = 64
  232.             End If
  233.             If chrs(2) = 0 Then
  234.                 enc(3) = 64
  235.             End If
  236.             For Each x As Integer In enc
  237.                 out.Append(key(x))
  238.             Next
  239.         Loop While i < input.Length
  240.         Return out.ToString
  241.     End Function
  242.     Public Function MEGAN35_Decode(ByVal input As String) As String
  243.         Dim key As String = "3GHIJKLMNOPQRSTUb=cdefghijklmnopWXYZ/12+406789VaqrstuvwxyzABCDEF5"
  244.         Dim out As New System.Text.StringBuilder
  245.         Dim i As Integer
  246.         Do
  247.             Dim enc(3) As Integer
  248.             Dim chrs() As Integer = {0, 0, 0}
  249.             For b As Integer = 0 To 3
  250.                 enc(b) = key.IndexOf(input(i))
  251.                 i = i + 1
  252.             Next
  253.             chrs(0) = (enc(0) << 2) Or (enc(1) >> 4)
  254.             chrs(1) = (enc(1) And 15) << 4 Or (enc(2) >> 2)
  255.             chrs(2) = (enc(2) And 3) << 6 Or enc(3)
  256.             out.Append(Chr(chrs(0)))
  257.             If enc(2) <> 64 Then out.Append(Chr(chrs(1)))
  258.             If enc(3) <> 64 Then out.Append(Chr(chrs(2)))
  259.         Loop While i < input.Length
  260.         Return out.ToString
  261.     End Function
  262. #End Region
  263. #Region "Zong 22"
  264.     Public Function ZONG22_Encode(ByVal input As String) As String
  265.         input = Uri.EscapeDataString(input)
  266.         Dim key As String = "ZKj9n+yf0wDVX1s/5YbdxSo=ILaUpPBCHg8uvNO4klm6iJGhQ7eFrWczAMEq3RTt2"
  267.         Dim out As New System.Text.StringBuilder
  268.         Dim i As Integer
  269.         Do
  270.             Dim enc(3) As Integer
  271.             Dim chrs As Integer() = {0, 0, 0}
  272.             For b As Integer = 0 To 2
  273.                 If i < input.Length Then chrs(b) = Asc(input(i))
  274.                 i += 1
  275.             Next
  276.             enc(0) = chrs(0) >> 2
  277.             enc(1) = ((chrs(0) And 3) << 4) Or (chrs(1) >> 4)
  278.             enc(2) = ((chrs(1) And 15) << 2) Or (chrs(2) >> 6)
  279.             enc(3) = chrs(2) And 63
  280.             If chrs(1) = 0 Then
  281.                 enc(2) = 64
  282.                 enc(3) = 64
  283.             End If
  284.             If chrs(2) = 0 Then
  285.                 enc(3) = 64
  286.             End If
  287.             For Each x As Integer In enc
  288.                 out.Append(key(x))
  289.             Next
  290.         Loop While i < input.Length
  291.         Return out.ToString
  292.     End Function
  293.     Public Function ZONG22_Decode(ByVal input As String) As String
  294.         Dim key As String = "ZKj9n+yf0wDVX1s/5YbdxSo=ILaUpPBCHg8uvNO4klm6iJGhQ7eFrWczAMEq3RTt2"
  295.         Dim out As New System.Text.StringBuilder
  296.         Dim i As Integer
  297.         Do
  298.             Dim enc(3) As Integer
  299.             Dim chrs() As Integer = {0, 0, 0}
  300.             For b As Integer = 0 To 3
  301.                 enc(b) = key.IndexOf(input(i))
  302.                 i = i + 1
  303.             Next
  304.             chrs(0) = (enc(0) << 2) Or (enc(1) >> 4)
  305.             chrs(1) = (enc(1) And 15) << 4 Or (enc(2) >> 2)
  306.             chrs(2) = (enc(2) And 3) << 6 Or enc(3)
  307.             out.Append(Chr(chrs(0)))
  308.             If enc(2) <> 64 Then out.Append(Chr(chrs(1)))
  309.             If enc(3) <> 64 Then out.Append(Chr(chrs(2)))
  310.         Loop While i < input.Length
  311.         Return out.ToString
  312.     End Function
  313. #End Region
  314. #Region "Tripo 5"
  315.     Public Function TRIPO5_Encode(ByVal input As String) As String
  316.         input = Uri.EscapeDataString(input)
  317.         Dim key As String = "ghijopE+G78lmnIJQRXY=abcS/UVWdefABCs456tDqruvNOPwx2KLyz01M3Hk9ZFT"
  318.         Dim out As New System.Text.StringBuilder
  319.         Dim i As Integer
  320.         Do
  321.             Dim enc(3) As Integer
  322.             Dim chrs As Integer() = {0, 0, 0}
  323.             For b As Integer = 0 To 2
  324.                 If i < input.Length Then chrs(b) = Asc(input(i))
  325.                 i += 1
  326.             Next
  327.             enc(0) = chrs(0) >> 2
  328.             enc(1) = ((chrs(0) And 3) << 4) Or (chrs(1) >> 4)
  329.             enc(2) = ((chrs(1) And 15) << 2) Or (chrs(2) >> 6)
  330.             enc(3) = chrs(2) And 63
  331.             If chrs(1) = 0 Then
  332.                 enc(2) = 64
  333.                 enc(3) = 64
  334.             End If
  335.             If chrs(2) = 0 Then
  336.                 enc(3) = 64
  337.             End If
  338.             For Each x As Integer In enc
  339.                 out.Append(key(x))
  340.             Next
  341.         Loop While i < input.Length
  342.         Return out.ToString
  343.     End Function
  344.     Public Function TRIPO5_Decode(ByVal input As String) As String
  345.         Dim key As String = "ghijopE+G78lmnIJQRXY=abcS/UVWdefABCs456tDqruvNOPwx2KLyz01M3Hk9ZFT"
  346.         Dim out As New System.Text.StringBuilder
  347.         Dim i As Integer
  348.         Do
  349.             Dim enc(3) As Integer
  350.             Dim chrs() As Integer = {0, 0, 0}
  351.             For b As Integer = 0 To 3
  352.                 enc(b) = key.IndexOf(input(i))
  353.                 i = i + 1
  354.             Next
  355.             chrs(0) = (enc(0) << 2) Or (enc(1) >> 4)
  356.             chrs(1) = (enc(1) And 15) << 4 Or (enc(2) >> 2)
  357.             chrs(2) = (enc(2) And 3) << 6 Or enc(3)
  358.             out.Append(Chr(chrs(0)))
  359.             If enc(2) <> 64 Then out.Append(Chr(chrs(1)))
  360.             If enc(3) <> 64 Then out.Append(Chr(chrs(2)))
  361.         Loop While i < input.Length
  362.         Return out.ToString
  363.     End Function
  364. #End Region
  365. #Region "TIGO3FX"
  366.     Public Function TIGO3FX_Encode(ByVal input As String) As String
  367.         input = Uri.EscapeDataString(input)
  368.         Dim key As String = "FrsxyzA8VtuvwDEqWZ/1+4klm67=cBCa5Ybdef0g2hij9nopMNO3GHIRSTJKLPQUX"
  369.         Dim out As New System.Text.StringBuilder
  370.         Dim i As Integer
  371.         Do
  372.             Dim enc(3) As Integer
  373.             Dim chrs As Integer() = {0, 0, 0}
  374.             For b As Integer = 0 To 2
  375.                 If i < input.Length Then chrs(b) = Asc(input(i))
  376.                 i += 1
  377.             Next
  378.             enc(0) = chrs(0) >> 2
  379.             enc(1) = ((chrs(0) And 3) << 4) Or (chrs(1) >> 4)
  380.             enc(2) = ((chrs(1) And 15) << 2) Or (chrs(2) >> 6)
  381.             enc(3) = chrs(2) And 63
  382.             If chrs(1) = 0 Then
  383.                 enc(2) = 64
  384.                 enc(3) = 64
  385.             End If
  386.             If chrs(2) = 0 Then
  387.                 enc(3) = 64
  388.             End If
  389.             For Each x As Integer In enc
  390.                 out.Append(key(x))
  391.             Next
  392.         Loop While i < input.Length
  393.         Return out.ToString
  394.     End Function
  395.     Public Function TIGO3FX_Decode(ByVal input As String) As String
  396.         Dim key As String = "FrsxyzA8VtuvwDEqWZ/1+4klm67=cBCa5Ybdef0g2hij9nopMNO3GHIRSTJKLPQUX"
  397.         Dim out As New System.Text.StringBuilder
  398.         Dim i As Integer
  399.         Do
  400.             Dim enc(3) As Integer
  401.             Dim chrs() As Integer = {0, 0, 0}
  402.             For b As Integer = 0 To 3
  403.                 enc(b) = key.IndexOf(input(i))
  404.                 i = i + 1
  405.             Next
  406.             chrs(0) = (enc(0) << 2) Or (enc(1) >> 4)
  407.             chrs(1) = (enc(1) And 15) << 4 Or (enc(2) >> 2)
  408.             chrs(2) = (enc(2) And 3) << 6 Or enc(3)
  409.             out.Append(Chr(chrs(0)))
  410.             If enc(2) <> 64 Then out.Append(Chr(chrs(1)))
  411.             If enc(3) <> 64 Then out.Append(Chr(chrs(2)))
  412.         Loop While i < input.Length
  413.         Return out.ToString
  414.     End Function
  415. #End Region
  416. #Region "FERON 74"
  417.     Public Function FERON74_Encode(ByVal input As String) As String
  418.         input = Uri.EscapeDataString(input)
  419.         Dim key As String = "75XYTabcS/UVWdefADqr6RuvN8PBCsQtwx2KLyz+OM3Hk9ghi01ZFlmnjopE=GIJ4"
  420.         Dim out As New System.Text.StringBuilder
  421.         Dim i As Integer
  422.         Do
  423.             Dim enc(3) As Integer
  424.             Dim chrs As Integer() = {0, 0, 0}
  425.             For b As Integer = 0 To 2
  426.                 If i < input.Length Then chrs(b) = Asc(input(i))
  427.                 i += 1
  428.             Next
  429.             enc(0) = chrs(0) >> 2
  430.             enc(1) = ((chrs(0) And 3) << 4) Or (chrs(1) >> 4)
  431.             enc(2) = ((chrs(1) And 15) << 2) Or (chrs(2) >> 6)
  432.             enc(3) = chrs(2) And 63
  433.             If chrs(1) = 0 Then
  434.                 enc(2) = 64
  435.                 enc(3) = 64
  436.             End If
  437.             If chrs(2) = 0 Then
  438.                 enc(3) = 64
  439.             End If
  440.             For Each x As Integer In enc
  441.                 out.Append(key(x))
  442.             Next
  443.         Loop While i < input.Length
  444.         Return out.ToString
  445.     End Function
  446.     Public Function FERON74_Decode(ByVal input As String) As String
  447.         Dim key As String = "75XYTabcS/UVWdefADqr6RuvN8PBCsQtwx2KLyz+OM3Hk9ghi01ZFlmnjopE=GIJ4"
  448.         Dim out As New System.Text.StringBuilder
  449.         Dim i As Integer
  450.         Do
  451.             Dim enc(3) As Integer
  452.             Dim chrs() As Integer = {0, 0, 0}
  453.             For b As Integer = 0 To 3
  454.                 enc(b) = key.IndexOf(input(i))
  455.                 i = i + 1
  456.             Next
  457.             chrs(0) = (enc(0) << 2) Or (enc(1) >> 4)
  458.             chrs(1) = (enc(1) And 15) << 4 Or (enc(2) >> 2)
  459.             chrs(2) = (enc(2) And 3) << 6 Or enc(3)
  460.             out.Append(Chr(chrs(0)))
  461.             If enc(2) <> 64 Then out.Append(Chr(chrs(1)))
  462.             If enc(3) <> 64 Then out.Append(Chr(chrs(2)))
  463.         Loop While i < input.Length
  464.         Return out.ToString
  465.     End Function
  466. #End Region
  467. #Region "ZARA 128"
  468.     Public Function ZARA128_Encode(ByVal input As String) As String
  469.         Dim out As New System.Text.StringBuilder
  470.         For Each c As Char In input
  471.             Dim temp As Integer = Asc(c) + 312
  472.             out.Append(temp.ToString & " ")
  473.         Next
  474.         Return out.ToString.Substring(0, out.Length - 1)
  475.     End Function
  476.     Public Function ZARA128_Decode(ByVal input As String) As String
  477.         Dim out As New System.Text.StringBuilder
  478.         Dim data As String() = Split(input, " ")
  479.         For Each s As String In data
  480.             out.Append(Chr(Asc(s) - 312))
  481.         Next
  482.         Return out.ToString
  483.     End Function
  484. #End Region
  485. #Region "Base 64"
  486.     Public Function BASE64_Encode(ByVal input As String) As String
  487.         Return Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(input))
  488.     End Function
  489.     Public Function BASE64_Decode(ByVal input As String) As String
  490.         Return System.Text.Encoding.ASCII.GetString(Convert.FromBase64String(input))
  491.     End Function
  492. #End Region
  493. #Region "ARMON 64"
  494.     Public Function ARMON64_Encrypt(ByVal message As String, Optional ByVal key As String = "ARMON64-CRYPO") As String
  495.         Dim out As New System.Text.StringBuilder
  496.         If key.Length < 3 Then Return message
  497.         Dim intkey() As Byte = System.Text.Encoding.UTF8.GetBytes(key)
  498.         Dim x As Integer
  499.         Do While x < message.Length
  500.             Dim hextemp As String = ""
  501.             Dim y As String = ""
  502.             If x > 0 Then y = "+"
  503.             For i As Integer = x To Math.Round(key.Length / 2)
  504.                 If i < message.Length Then hextemp += Hex(Asc(message(i)))
  505.             Next
  506.             Dim thenum As Double = "&H" & hextemp
  507.             If Information.IsNumeric(thenum) = False Then Return message
  508.             For z As Integer = 0 To key.Length - 1
  509.                 Dim operation As Integer = z Mod 4
  510.                 Select Case operation
  511.                     Case 0
  512.                         thenum += intkey(z)
  513.                     Case 1
  514.                         thenum /= intkey(z)
  515.                     Case 2
  516.                         thenum -= intkey(z)
  517.                     Case 3
  518.                         thenum *= 0.01 * intkey(z)
  519.                 End Select
  520.             Next
  521.             out.Append(y & thenum)
  522.             x += Math.Round(key.Length / 2)
  523.         Loop
  524.         Return out.ToString.Replace(",", ".")
  525.     End Function
  526.     Public Function ARMON64_Decrypt(ByVal message As String, Optional ByVal key As String = "ARMON64-CRYPO") As String
  527.         Dim out As New System.Text.StringBuilder
  528.         If key.Length < 6 Then Return message
  529.         Dim intkey() As Byte = System.Text.Encoding.UTF8.GetBytes(key)
  530.         message = message.Replace(".", ",")
  531.         Dim oOutString As String() = Split(message, "+")
  532.         For x As Integer = 0 To oOutString.Length - 1
  533.             For z As Integer = key.Length - 1 To 0 Step -1
  534.                 Dim operation As Integer = z Mod 4
  535.                 Select Case operation
  536.                     Case 0
  537.                         oOutString(x) -= intkey(z)
  538.                     Case 1
  539.                         oOutString(x) *= intkey(z)
  540.                     Case 2
  541.                         oOutString(x) += intkey(z)
  542.                     Case 3
  543.                         oOutString(x) /= 0.01 * intkey(z)
  544.                 End Select
  545.             Next
  546.             oOutString(x) = Hex(Math.Round(Double.Parse(oOutString(x))))
  547.         Next
  548.         For i As Integer = 0 To Join(oOutString).Length - 1 Step +2
  549.             out.Append(Chr(("&H" & Join(oOutString).Substring(i, 2))))
  550.         Next
  551.         Return out.ToString
  552.     End Function
  553. #End Region
  554. #Region "AER 256"
  555.     Public Function AER256_Encrypt(ByVal message As String, Optional ByVal key As String = "A256-CRYPO") As String
  556.         Dim out As New System.Text.StringBuilder
  557.         If key.Length < 10 Then Return message
  558.         Dim intkey() As Byte = System.Text.Encoding.UTF8.GetBytes(key)
  559.         Dim x As Integer
  560.         Do While x < message.Length
  561.             Dim hextemp As String = ""
  562.             Dim y As String = ""
  563.             If x > 0 Then y = ", "
  564.             For i As Integer = x To Math.Round(key.Length / 2)
  565.                 If i < message.Length Then hextemp += Hex(Asc(message(i)))
  566.             Next
  567.             Dim thenum As Double = "&H" & hextemp
  568.             If Information.IsNumeric(thenum) = False Then Return message
  569.             For z As Integer = 0 To key.Length - 1
  570.                 Dim operation As Integer = z Mod 3
  571.                 Select Case operation
  572.                     Case 0
  573.                         thenum += intkey(z)
  574.                     Case 1
  575.                         thenum /= intkey(z)
  576.                     Case 2
  577.                         thenum -= intkey(z)
  578.                     Case 3
  579.                         thenum *= 0.02 * intkey(z)
  580.                 End Select
  581.             Next
  582.             Dim temp As String = thenum.ToString.Replace(",", ".")
  583.             out.Append(y & temp)
  584.             x += Math.Round(key.Length / 2)
  585.         Loop
  586.         Return out.ToString
  587.     End Function
  588.     Public Function AER256_Decrypt(ByVal message As String, Optional ByVal key As String = "A256-CRYPO") As String
  589.         Dim out As New System.Text.StringBuilder
  590.         If key.Length < 10 Then Return message
  591.         Dim intkey() As Byte = System.Text.Encoding.UTF8.GetBytes(key)
  592.  
  593.         Dim oOutString As String() = Split(message, ", ")
  594.         For i As Integer = 0 To oOutString.Length - 1
  595.             oOutString(i) = oOutString(i).Replace(".", ",")
  596.         Next
  597.         For x As Integer = 0 To oOutString.Length - 1
  598.             For z As Integer = key.Length - 1 To 0 Step -1
  599.                 Dim operation As Integer = z Mod 3
  600.                 Select Case operation
  601.                     Case 0
  602.                         oOutString(x) -= intkey(z)
  603.                     Case 1
  604.                         oOutString(x) *= intkey(z)
  605.                     Case 2
  606.                         oOutString(x) += intkey(z)
  607.                     Case 3
  608.                         oOutString(x) /= 0.02 * intkey(z)
  609.                 End Select
  610.             Next
  611.             oOutString(x) = Hex(Math.Round(Double.Parse(oOutString(x))))
  612.         Next
  613.         For i As Integer = 0 To Join(oOutString).Length - 1 Step +2
  614.             out.Append(Chr(("&H" & Join(oOutString).Substring(i, 2))))
  615.         Next
  616.         Return out.ToString
  617.     End Function
  618. #End Region
  619. #Region "EZIP 64"
  620.     Public Function EZIP64_Encrypt(ByVal message As String, Optional ByVal key As String = "EZIP64-CRYPO") As String
  621.         Dim out As New System.Text.StringBuilder
  622.         If key.Length < 10 Then Return message
  623.         Dim intkey() As Byte = System.Text.Encoding.UTF8.GetBytes(key)
  624.         Dim x As Integer
  625.         Do While x < message.Length
  626.             Dim hextemp As String = ""
  627.             Dim y As String = ""
  628.             If x > 0 Then y = "/"
  629.             For i As Integer = x To Math.Round(key.Length / 3)
  630.                 If i < message.Length Then hextemp += Hex(Asc(message(i)))
  631.             Next
  632.             Dim thenum As Double = "&H" & hextemp
  633.             If Information.IsNumeric(thenum) = False Then Return message
  634.             For z As Integer = 0 To key.Length - 1
  635.                 Dim operation As Integer = z Mod 4
  636.                 Select Case operation
  637.                     Case 0
  638.                         thenum += intkey(z)
  639.                     Case 1
  640.                         thenum /= intkey(z)
  641.                     Case 2
  642.                         thenum -= intkey(z)
  643.                     Case 3
  644.                         thenum *= 0.02 * intkey(z)
  645.                 End Select
  646.             Next
  647.             Dim temp As String = thenum.ToString.Replace(",", ".")
  648.             out.Append(y & temp)
  649.             x += Math.Round(key.Length / 3)
  650.         Loop
  651.         Return out.ToString
  652.     End Function
  653.     Public Function EZIP64_Decrypt(ByVal message As String, Optional ByVal key As String = "EZIP64-CRYPO") As String
  654.         Dim out As New System.Text.StringBuilder
  655.         If key.Length < 10 Then Return message
  656.         Dim intkey() As Byte = System.Text.Encoding.UTF8.GetBytes(key)
  657.  
  658.         Dim oOutString As String() = Split(message, "/")
  659.         For i As Integer = 0 To oOutString.Length - 1
  660.             oOutString(i) = oOutString(i).Replace(".", ",")
  661.         Next
  662.         For x As Integer = 0 To oOutString.Length - 1
  663.             For z As Integer = key.Length - 1 To 0 Step -1
  664.                 Dim operation As Integer = z Mod 4
  665.                 Select Case operation
  666.                     Case 0
  667.                         oOutString(x) -= intkey(z)
  668.                     Case 1
  669.                         oOutString(x) *= intkey(z)
  670.                     Case 2
  671.                         oOutString(x) += intkey(z)
  672.                     Case 3
  673.                         oOutString(x) /= 0.02 * intkey(z)
  674.                 End Select
  675.             Next
  676.             oOutString(x) = Hex(Math.Round(Double.Parse(oOutString(x))))
  677.         Next
  678.         For i As Integer = 0 To Join(oOutString).Length - 1 Step +2
  679.             out.Append(Chr(("&H" & Join(oOutString).Substring(i, 2))))
  680.             Dim j As String = out.ToString
  681.         Next
  682.         Return out.ToString
  683.     End Function
  684. #End Region
  685. #Region "OKTO3"
  686.     Public Function OKTO3_Encrypt(ByVal message As String, Optional ByVal key As String = "PASS:OKTO3-CRYPO") As String
  687.         Dim out As New System.Text.StringBuilder
  688.         If key.Length < 10 Then Return message
  689.         Dim intkey() As Byte = System.Text.Encoding.UTF8.GetBytes(key)
  690.         Dim x As Integer
  691.         Do While x < message.Length
  692.             Dim hextemp As String = ""
  693.             Dim y As String = ""
  694.             If x > 0 Then y = ", "
  695.             For i As Integer = x To Math.Round(key.Length / 6)
  696.                 If i < message.Length Then hextemp += Hex(Asc(message(i)))
  697.             Next
  698.             Dim thenum As Double = "&H" & hextemp
  699.             If Information.IsNumeric(thenum) = False Then Return message
  700.             For z As Integer = 0 To key.Length - 1
  701.                 Dim operation As Integer = z Mod 3
  702.                 Select Case operation
  703.                     Case 0
  704.                         thenum += intkey(z)
  705.                     Case 1
  706.                         thenum /= intkey(z)
  707.                     Case 2
  708.                         thenum -= intkey(z)
  709.                     Case 3
  710.                         thenum *= 500.005 * intkey(z)
  711.                 End Select
  712.             Next
  713.             Dim temp As String = thenum.ToString.Replace(",", ".")
  714.             out.Append(y & temp)
  715.             x += Math.Round(key.Length / 6)
  716.         Loop
  717.         Return out.ToString
  718.     End Function
  719.     Public Function OKTO3_Decrypt(ByVal message As String, Optional ByVal key As String = "PASS:OKTO3-CRYPO") As String
  720.         Dim out As New System.Text.StringBuilder
  721.         If key.Length < 10 Then Return message
  722.         Dim intkey() As Byte = System.Text.Encoding.UTF8.GetBytes(key)
  723.  
  724.         Dim oOutString As String() = Split(message, ", ")
  725.         For i As Integer = 0 To oOutString.Length - 1
  726.             oOutString(i) = oOutString(i).Replace(".", ",")
  727.         Next
  728.         For x As Integer = 0 To oOutString.Length - 1
  729.             For z As Integer = key.Length - 1 To 0 Step -1
  730.                 Dim operation As Integer = z Mod 3
  731.                 Select Case operation
  732.                     Case 0
  733.                         oOutString(x) -= intkey(z)
  734.                     Case 1
  735.                         oOutString(x) *= intkey(z)
  736.                     Case 2
  737.                         oOutString(x) += intkey(z)
  738.                     Case 3
  739.                         oOutString(x) /= 0.02 * intkey(z)
  740.                 End Select
  741.             Next
  742.             oOutString(x) = Hex(Math.Round(Double.Parse(oOutString(x))))
  743.         Next
  744.         For i As Integer = 0 To Join(oOutString).Length - 1 Step +2
  745.             out.Append(Chr(("&H" & Join(oOutString).Substring(i, 2))))
  746.         Next
  747.         Return out.ToString
  748.     End Function
  749. #End Region
  750. #Region "Rc4"
  751.  Public Shared Function rc4(ByVal message As String, ByVal password As String) As String
  752.         Dim i As Integer = 0
  753.         Dim j As Integer = 0
  754.         Dim cipher As New StringBuilder
  755.         Dim returnCipher As String = String.Empty
  756.         Dim sbox As Integer() = New Integer(256) {}
  757.         Dim key As Integer() = New Integer(256) {}
  758.         Dim intLength As Integer = password.Length
  759.         Dim a As Integer = 0
  760.         While a <= 255
  761.             Dim ctmp As Char = (password.Substring((a Mod intLength), 1).ToCharArray()(0))
  762.             key(a) = Microsoft.VisualBasic.Strings.Asc(ctmp)
  763.             sbox(a) = a
  764.             System.Math.Max(System.Threading.Interlocked.Increment(a), a - 1)
  765.         End While
  766.         Dim x As Integer = 0
  767.         Dim b As Integer = 0
  768.         While b <= 255
  769.             x = (x + sbox(b) + key(b)) Mod 256
  770.             Dim tempSwap As Integer = sbox(b)
  771.             sbox(b) = sbox(x)
  772.             sbox(x) = tempSwap
  773.             System.Math.Max(System.Threading.Interlocked.Increment(b), b - 1)
  774.         End While
  775.         a = 1
  776.         While a <= message.Length
  777.             Dim itmp As Integer = 0
  778.             i = (i + 1) Mod 256
  779.             j = (j + sbox(i)) Mod 256
  780.             itmp = sbox(i)
  781.             sbox(i) = sbox(j)
  782.             sbox(j) = itmp
  783.             Dim k As Integer = sbox((sbox(i) + sbox(j)) Mod 256)
  784.             Dim ctmp As Char = message.Substring(a - 1, 1).ToCharArray()(0)
  785.             itmp = Asc(ctmp)
  786.             Dim cipherby As Integer = itmp Xor k
  787.             cipher.Append(Chr(cipherby))
  788.             System.Math.Max(System.Threading.Interlocked.Increment(a), a - 1)
  789.         End While
  790.         returnCipher = cipher.ToString
  791.         cipher.Length = 0
  792.         Return returnCipher
  793.     End Function
  794. #End Region
  795. #Region "Hashs"
  796.     Public Function MD5Hash(ByVal input As String) As String
  797.         Dim MD5 As New System.Security.Cryptography.MD5CryptoServiceProvider
  798.         Dim Data As Byte()
  799.         Dim Result As Byte()
  800.         Dim Res As String = ""
  801.         Dim Tmp As String = ""
  802.         Data = System.Text.Encoding.ASCII.GetBytes(input)
  803.         Result = MD5.ComputeHash(Data)
  804.         For i As Integer = 0 To Result.Length - 1
  805.             Tmp = Hex(Result(i))
  806.             If Len(Tmp) = 1 Then Tmp = "0" & Tmp
  807.             Res += Tmp
  808.         Next
  809.         Return Res
  810.     End Function
  811.     Public Function RIPEMD160Hash(ByVal input As String) As String
  812.         Dim RIPEMD160 As New System.Security.Cryptography.RIPEMD160Managed
  813.         Dim Data As Byte()
  814.         Dim Result As Byte()
  815.         Dim Res As String = ""
  816.         Dim Tmp As String = ""
  817.         Data = System.Text.Encoding.ASCII.GetBytes(input)
  818.         Result = RIPEMD160.ComputeHash(Data)
  819.         For i As Integer = 0 To Result.Length - 1
  820.             Tmp = Hex(Result(i))
  821.             If Len(Tmp) = 1 Then Tmp = "0" & Tmp
  822.             Res += Tmp
  823.         Next
  824.         Return Res
  825.     End Function
  826.     Public Function SHA1Hash(ByVal input As String) As String
  827.         Dim SHA1 As New System.Security.Cryptography.SHA1CryptoServiceProvider
  828.         Dim Data As Byte()
  829.         Dim Result As Byte()
  830.         Dim Res As String = ""
  831.         Dim Tmp As String = ""
  832.         Data = System.Text.Encoding.ASCII.GetBytes(input)
  833.         Result = SHA1.ComputeHash(Data)
  834.         For i As Integer = 0 To Result.Length - 1
  835.             Tmp = Hex(Result(i))
  836.             If Len(Tmp) = 1 Then Tmp = "0" & Tmp
  837.             Res += Tmp
  838.         Next
  839.         Return Res
  840.     End Function
  841.     Public Function SHA256Hash(ByVal input As String) As String
  842.         Dim SHA256 As New System.Security.Cryptography.SHA256Managed
  843.         Dim Data As Byte()
  844.         Dim Result As Byte()
  845.         Dim Res As String = ""
  846.         Dim Tmp As String = ""
  847.         Data = System.Text.Encoding.ASCII.GetBytes(input)
  848.         Result = SHA256.ComputeHash(Data)
  849.         For i As Integer = 0 To Result.Length - 1
  850.             Tmp = Hex(Result(i))
  851.             If Len(Tmp) = 1 Then Tmp = "0" & Tmp
  852.             Res += Tmp
  853.         Next
  854.         Return Res
  855.     End Function
  856.     Public Function SHA348Hash(ByVal input As String) As String
  857.         Dim SHA348 As New System.Security.Cryptography.SHA384Managed
  858.         Dim Data As Byte()
  859.         Dim Result As Byte()
  860.         Dim Res As String = ""
  861.         Dim Tmp As String = ""
  862.         Data = System.Text.Encoding.ASCII.GetBytes(input)
  863.         Result = SHA348.ComputeHash(Data)
  864.         For i As Integer = 0 To Result.Length - 1
  865.             Tmp = Hex(Result(i))
  866.             If Len(Tmp) = 1 Then Tmp = "0" & Tmp
  867.             Res += Tmp
  868.         Next
  869.         Return Res
  870.     End Function
  871.     Public Function SHA512Hash(ByVal input As String) As String
  872.         Dim SHA512 As New System.Security.Cryptography.SHA512Managed
  873.         Dim Data As Byte()
  874.         Dim Result As Byte()
  875.         Dim Res As String = ""
  876.         Dim Tmp As String = ""
  877.         Data = System.Text.Encoding.ASCII.GetBytes(input)
  878.         Result = SHA512.ComputeHash(Data)
  879.         For i As Integer = 0 To Result.Length - 1
  880.             Tmp = Hex(Result(i))
  881.             If Len(Tmp) = 1 Then Tmp = "0" & Tmp
  882.             Res += Tmp
  883.         Next
  884.         Return Res
  885.     End Function
  886. #End Region
  887. #Region "Chiffre de CĂ©sar"
  888.     Public Function Encrypt(ByVal PlainText As String, ByVal Key As Integer) As String
  889.         Dim PlainChar() As Char = PlainText.ToCharArray()
  890.         Dim Ascii(PlainChar.Length) As Integer
  891.         For Count As Integer = 0 To PlainChar.Length - 1
  892.             Ascii(Count) = Asc(PlainChar(Count))
  893.             If Ascii(Count) >= 65 And Ascii(Count) <= 90 Then
  894.                 Ascii(Count) = ((Ascii(Count) - 65 + Key) Mod 26) + 65
  895.             ElseIf Ascii(Count) >= 97 And Ascii(Count) <= 122 Then
  896.                 Ascii(Count) = ((Ascii(Count) - 97 + Key) Mod 26) + 97
  897.             End If
  898.             PlainChar(Count) = Chr(Ascii(Count))
  899.         Next
  900.         Return PlainChar
  901.     End Function
  902.     Public Function Decrypt(ByVal CipherText As String, ByVal Key As Integer) As String
  903.         Dim CipherChar() As Char = CipherText.ToCharArray()
  904.         Dim Ascii(CipherChar.Length) As Integer
  905.  
  906.         For Count As Integer = 0 To CipherChar.Length - 1
  907.             Ascii(Count) = Asc(CipherChar(Count))
  908.             If Ascii(Count) >= 65 And Ascii(Count) <= 90 Then
  909.                 Ascii(Count) = ((Ascii(Count) - 65 - (Key Mod 26) + 26)) Mod 26 + 65
  910.             ElseIf Ascii(Count) >= 97 And Ascii(Count) <= 122 Then
  911.                 Ascii(Count) = (((Ascii(Count) - 97 - (Key Mod 26) + 26)) Mod 26) + 97
  912.             End If
  913.             CipherChar(Count) = Chr(Ascii(Count))
  914.         Next
  915.         Return CipherChar
  916.     End Function
  917. #End Region
  918. #Region "ROT13"
  919.     Public Function ROT13(ByVal input As String) As String
  920.         Dim out As New System.Text.StringBuilder
  921.         For i As Integer = 0 To input.Length - 1
  922.             out.Append(Chr(Asc(input(i)) Xor 13))
  923.         Next
  924.         Return out.ToString
  925.     End Function
  926. #End Region
  927. #Region "RSA"
  928.     Public Function RSA_Encrypt(ByVal Input As String) As String
  929.         Dim cp As New Security.Cryptography.CspParameters
  930.         cp.Flags = Security.Cryptography.CspProviderFlags.UseMachineKeyStore
  931.         cp.KeyContainerName = "Keys"
  932.         Dim RSA As New Security.Cryptography.RSACryptoServiceProvider(cp)
  933.  
  934.         Dim buffer As Byte() = System.Text.Encoding.UTF8.GetBytes(Input)
  935.         Dim encrypted As Byte() = RSA.Encrypt(buffer, True)
  936.         Return Convert.ToBase64String(encrypted)
  937.     End Function
  938.     Public Function RSA_Decrypt(ByVal Input As String) As String
  939.         Dim cp As New Security.Cryptography.CspParameters
  940.         cp.Flags = Security.Cryptography.CspProviderFlags.UseMachineKeyStore
  941.         cp.KeyContainerName = "Keys"
  942.         Dim RSA As New Security.Cryptography.RSACryptoServiceProvider(cp)
  943.         Dim buffer As Byte() = Convert.FromBase64String(Input)
  944.         Dim decrypted As Byte() = RSA.Decrypt(buffer, True)
  945.         Return System.Text.Encoding.UTF8.GetString(decrypted)
  946.     End Function
  947. #End Region
  948. #Region "XOR"
  949. #Region "Normale"
  950.     Public Function XOR_Encrypt(ByVal Input As String, ByVal pass As String) As String
  951.         Dim out As New System.Text.StringBuilder
  952.         Dim u As Integer
  953.         For i As Integer = 0 To Input.Length - 1
  954.             Dim tmp As String = Hex(Asc(Input(i)) Xor Asc(pass(u)))
  955.             If tmp.Length = 1 Then tmp = "0" & tmp
  956.             out.Append(tmp)
  957.             If u = pass.Length - 1 Then u = 0 Else u = u + 1
  958.         Next
  959.         Return out.ToString
  960.     End Function
  961.     Public Function XOR_Decrypt(ByVal Input As String, ByVal pass As String) As String
  962.         Dim out As New System.Text.StringBuilder
  963.         Dim u As Integer
  964.         For i As Integer = 0 To Input.Length - 1 Step +2
  965.             Dim tmp As String = Chr(("&H" & Input.Substring(i, 2)) Xor Asc(pass(u)))
  966.             out.Append(tmp)
  967.             If u = pass.Length - 1 Then u = 0 Else u = u + 1
  968.         Next
  969.         Return out.ToString
  970.     End Function
  971. #End Region
  972. #Region "Personnalisée"
  973.  
  974.     Public Function CustomXOR_Encrypt(ByVal Input As String, ByVal pass As String) As String
  975.         Dim out As New System.Text.StringBuilder
  976.         Dim Hash As New System.Security.Cryptography.MD5CryptoServiceProvider
  977.         Dim XorHash As Byte() = Hash.ComputeHash(System.Text.Encoding.ASCII.GetBytes(pass))
  978.         Dim u As Integer
  979.         For i As Integer = 0 To Input.Length - 1
  980.             Dim tmp As String = Hex(Asc(Input(i)) Xor XorHash(u))
  981.             If tmp.Length = 1 Then tmp = "0" & tmp
  982.             out.Append(tmp)
  983.             If u = pass.Length - 1 Then u = 0 Else u = u + 1
  984.         Next
  985.         Return out.ToString
  986.     End Function
  987.     Public Function CustomXOR_Decrypt(ByVal Input As String, ByVal pass As String) As String
  988.         Dim out As New System.Text.StringBuilder
  989.         Dim Hash As New System.Security.Cryptography.MD5CryptoServiceProvider
  990.         Dim XorHash As Byte() = Hash.ComputeHash(System.Text.Encoding.ASCII.GetBytes(pass))
  991.         Dim u As Integer
  992.         For i As Integer = 0 To Input.Length - 1 Step +2
  993.             Dim tmp As String = Chr(("&H" & Input.Substring(i, 2)) Xor XorHash(u))
  994.             out.Append(tmp)
  995.             If u = pass.Length - 1 Then u = 0 Else u = u + 1
  996.         Next
  997.         Return out.ToString
  998.     End Function
  999.  
  1000. #End Region
  1001. #End Region
  1002. #Region "Rc2"
  1003.     Public Function RC2_Encrypt(ByVal input As String, ByVal pass As String) As String
  1004.         Dim RC2 As New System.Security.Cryptography.RC2CryptoServiceProvider
  1005.         Dim Hash_RC2 As New System.Security.Cryptography.MD5CryptoServiceProvider
  1006.         Dim encrypted As String = ""
  1007.         Try
  1008.             Dim hash() As Byte = Hash_RC2.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
  1009.  
  1010.             RC2.Key = hash
  1011.             RC2.Mode = Security.Cryptography.CipherMode.ECB
  1012.             Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = RC2.CreateEncryptor
  1013.             Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(input)
  1014.             encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
  1015.             Return encrypted
  1016.         Catch ex As Exception
  1017.         End Try
  1018.     End Function
  1019.     Public Function RC2_Decrypt(ByVal input As String, ByVal pass As String) As String
  1020.         Dim RC2 As New System.Security.Cryptography.RC2CryptoServiceProvider
  1021.         Dim Hash_RC2 As New System.Security.Cryptography.MD5CryptoServiceProvider
  1022.         Dim decrypted As String = ""
  1023.         Try
  1024.             Dim hash() As Byte = Hash_RC2.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
  1025.             RC2.Key = hash
  1026.             RC2.Mode = Security.Cryptography.CipherMode.ECB
  1027.             Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = RC2.CreateDecryptor
  1028.             Dim Buffer As Byte() = Convert.FromBase64String(input)
  1029.             decrypted = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
  1030.             Return decrypted
  1031.         Catch ex As Exception
  1032.         End Try
  1033.     End Function
  1034. #End Region
  1035. #Region "DES"
  1036.     Public Function DES_Encrypt(ByVal input As String, ByVal pass As String) As String
  1037.         Dim DES As New System.Security.Cryptography.DESCryptoServiceProvider
  1038.         Dim Hash_DES As New System.Security.Cryptography.MD5CryptoServiceProvider
  1039.         Dim encrypted As String = ""
  1040.         Try
  1041.             Dim hash(7) As Byte
  1042.             Dim temp As Byte() = Hash_DES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
  1043.             Array.Copy(temp, 0, hash, 0, 8)
  1044.             DES.Key = hash
  1045.             DES.Mode = Security.Cryptography.CipherMode.ECB
  1046.             Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = DES.CreateEncryptor
  1047.             Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(input)
  1048.             encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
  1049.             Return encrypted
  1050.         Catch ex As Exception
  1051.         End Try
  1052.     End Function
  1053.     Public Function DES_Decrypt(ByVal input As String, ByVal pass As String) As String
  1054.         Dim DES As New System.Security.Cryptography.DESCryptoServiceProvider
  1055.         Dim Hash_DES As New System.Security.Cryptography.MD5CryptoServiceProvider
  1056.         Dim decrypted As String = ""
  1057.         Try
  1058.             Dim hash(7) As Byte
  1059.             Dim temp As Byte() = Hash_DES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
  1060.             Array.Copy(temp, 0, hash, 0, 8)
  1061.             DES.Key = hash
  1062.             DES.Mode = Security.Cryptography.CipherMode.ECB
  1063.             Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = DES.CreateDecryptor
  1064.             Dim Buffer As Byte() = Convert.FromBase64String(input)
  1065.             decrypted = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
  1066.             Return decrypted
  1067.         Catch ex As Exception
  1068.         End Try
  1069.     End Function
  1070. #End Region
  1071. #Region "Triple DES"
  1072.     Public Function TripleDES_Encrypt(ByVal input As String, ByVal pass As String) As String
  1073.         Dim TripleDES As New System.Security.Cryptography.TripleDESCryptoServiceProvider
  1074.         Dim Hash_TripleDES As New System.Security.Cryptography.MD5CryptoServiceProvider
  1075.         Dim encrypted As String = ""
  1076.         Try
  1077.             Dim hash(23) As Byte
  1078.             Dim temp As Byte() = Hash_TripleDES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
  1079.             Array.Copy(temp, 0, hash, 0, 16)
  1080.             Array.Copy(temp, 0, hash, 15, 8)
  1081.             TripleDES.Key = hash
  1082.             TripleDES.Mode = Security.Cryptography.CipherMode.ECB
  1083.             Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = TripleDES.CreateEncryptor
  1084.             Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(input)
  1085.             encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
  1086.             Return encrypted
  1087.         Catch ex As Exception
  1088.         End Try
  1089.     End Function
  1090.     Public Function TripleDES_Decrypt(ByVal input As String, ByVal pass As String) As String
  1091.         Dim TripleDES As New System.Security.Cryptography.TripleDESCryptoServiceProvider
  1092.         Dim Hash_TripleDES As New System.Security.Cryptography.MD5CryptoServiceProvider
  1093.         Dim decrypted As String = ""
  1094.         Try
  1095.             Dim hash(23) As Byte
  1096.             Dim temp As Byte() = Hash_TripleDES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
  1097.             Array.Copy(temp, 0, hash, 0, 16)
  1098.             Array.Copy(temp, 0, hash, 15, 8)
  1099.             TripleDES.Key = hash
  1100.             TripleDES.Mode = Security.Cryptography.CipherMode.ECB
  1101.             Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = TripleDES.CreateDecryptor
  1102.             Dim Buffer As Byte() = Convert.FromBase64String(input)
  1103.             decrypted = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
  1104.             Return decrypted
  1105.         Catch ex As Exception
  1106.         End Try
  1107.     End Function
  1108.  
  1109. #End Region
  1110. #Region "AES"
  1111.     Public Function AES_Encrypt(ByVal input As String, ByVal pass As String) As String
  1112.         Dim AES As New System.Security.Cryptography.RijndaelManaged
  1113.         Dim Hash_AES As New System.Security.Cryptography.MD5CryptoServiceProvider
  1114.         Dim encrypted As String = ""
  1115.         Try
  1116.             Dim hash(31) As Byte
  1117.             Dim temp As Byte() = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
  1118.             Array.Copy(temp, 0, hash, 0, 16)
  1119.             Array.Copy(temp, 0, hash, 15, 16)
  1120.             AES.Key = hash
  1121.             AES.Mode = Security.Cryptography.CipherMode.ECB
  1122.             Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = AES.CreateEncryptor
  1123.             Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(input)
  1124.             encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
  1125.             Return encrypted
  1126.         Catch ex As Exception
  1127.         End Try
  1128.     End Function
  1129.     Public Function AES_Decrypt(ByVal input As String, ByVal pass As String) As String
  1130.         Dim AES As New System.Security.Cryptography.RijndaelManaged
  1131.         Dim Hash_AES As New System.Security.Cryptography.MD5CryptoServiceProvider
  1132.         Dim decrypted As String = ""
  1133.         Try
  1134.             Dim hash(31) As Byte
  1135.             Dim temp As Byte() = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
  1136.             Array.Copy(temp, 0, hash, 0, 16)
  1137.             Array.Copy(temp, 0, hash, 15, 16)
  1138.             AES.Key = hash
  1139.             AES.Mode = Security.Cryptography.CipherMode.ECB
  1140.             Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = AES.CreateDecryptor
  1141.             Dim Buffer As Byte() = Convert.FromBase64String(input)
  1142.             decrypted = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
  1143.             Return decrypted
  1144.         Catch ex As Exception
  1145.         End Try
  1146.     End Function
  1147. #End Region
  1148. #Region "Chaîne renversée"
  1149.     Public Function ReverseString(ByRef strToReverse As String) As String
  1150.         Dim result As String = ""
  1151.         For i As Integer = 0 To strToReverse.Length - 1
  1152.             result += strToReverse(strToReverse.Length - 1 - i)
  1153.         Next
  1154.         Return result
  1155.     End Function
  1156. #End Region
  1157. #Region "Rijndael"
  1158.     Public Shared Function RijndaelDecrypt(ByVal UDecryptU As String, ByVal UKeyU As String)
  1159.         Dim XoAesProviderX As New RijndaelManaged
  1160.         Dim XbtCipherX() As Byte
  1161.         Dim XbtSaltX() As Byte = New Byte() {1, 2, 3, 4, 5, 6, 7, 8}
  1162.         Dim XoKeyGeneratorX As New Rfc2898DeriveBytes(UKeyU, XbtSaltX)
  1163.         XoAesProviderX.Key = XoKeyGeneratorX.GetBytes(XoAesProviderX.Key.Length)
  1164.         XoAesProviderX.IV = XoKeyGeneratorX.GetBytes(XoAesProviderX.IV.Length)
  1165.         Dim XmsX As New IO.MemoryStream
  1166.         Dim XcsX As New CryptoStream(XmsX, XoAesProviderX.CreateDecryptor(), _
  1167.           CryptoStreamMode.Write)
  1168.         Try
  1169.             XbtCipherX = Convert.FromBase64String(UDecryptU)
  1170.             XcsX.Write(XbtCipherX, 0, XbtCipherX.Length)
  1171.             XcsX.Close()
  1172.             UDecryptU = System.Text.Encoding.UTF8.GetString(XmsX.ToArray)
  1173.         Catch
  1174.         End Try
  1175.         Return UDecryptU
  1176.     End Function
  1177.     Public Shared Function Rijndaelcrypt(ByVal File As String, ByVal Key As String)
  1178.         Dim oAesProvider As New RijndaelManaged
  1179.         Dim btClear() As Byte
  1180.         Dim btSalt() As Byte = New Byte() {1, 2, 3, 4, 5, 6, 7, 8}
  1181.         Dim oKeyGenerator As New Rfc2898DeriveBytes(Key, btSalt)
  1182.         oAesProvider.Key = oKeyGenerator.GetBytes(oAesProvider.Key.Length)
  1183.         oAesProvider.IV = oKeyGenerator.GetBytes(oAesProvider.IV.Length)
  1184.         Dim ms As New IO.MemoryStream
  1185.         Dim cs As New CryptoStream(ms, _
  1186.           oAesProvider.CreateEncryptor(), _
  1187.           CryptoStreamMode.Write)
  1188.         btClear = System.Text.Encoding.UTF8.GetBytes(File)
  1189.         cs.Write(btClear, 0, btClear.Length)
  1190.         cs.Close()
  1191.         File = Convert.ToBase64String(ms.ToArray)
  1192.         Return File
  1193.     End Function
  1194. #End Region
  1195. #Region "Hexadécimal"
  1196.     Public Function String2Hex(ByVal input As String) As String
  1197.         Dim out As New System.Text.StringBuilder
  1198.         For Each c As String In input
  1199.             Dim temp As String = Hex(Asc(c))
  1200.             out.Append(temp & " ")
  1201.         Next
  1202.         Return out.ToString.Substring(0, out.Length - 1)
  1203.     End Function
  1204.     Public Function Hex2String(ByVal input As String) As String
  1205.         Dim out As New System.Text.StringBuilder
  1206.         Dim data As String() = Split(input, " ")
  1207.         For Each s As String In data
  1208.             out.Append(Chr("&H" & s))
  1209.         Next
  1210.         Return out.ToString
  1211.     End Function
  1212. #End Region
  1213. #Region "Binaire"
  1214.     Private Function ConvertToAscii(ByVal str As String) As String
  1215.         Dim chars As String = Regex.Replace(str, "[^01]", "")
  1216.         Dim arr((chars.Length / 8) - 1) As Byte
  1217.         For i As Integer = 0 To arr.Length - 1
  1218.             arr(i) = Convert.ToByte(chars.Substring(i * 8, 8), 2)
  1219.         Next
  1220.         Return ASCIIEncoding.ASCII.GetString(arr)
  1221.     End Function
  1222.     Private Function ConvertToBinary(ByVal str As String) As String
  1223.         Dim converted As New StringBuilder
  1224.         For Each b As Byte In ASCIIEncoding.ASCII.GetBytes(str)
  1225.             converted.Append(Convert.ToString(b, 2).PadLeft(8, "0"))
  1226.         Next
  1227.         Return converted.ToString()
  1228.     End Function
  1229. #End Region
  1230. End Class
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top