Function Crypte(ByVal MotDePasse As String) As String Dim Str As String = MotDePasse Dim Emplac As String = "" Dim St As String = "" Dim Txt As String = "" Dim Nombre As Integer = CInt(MotDePasse.Length / 2) Dim Tabl(Nombre) As Integer Dim Rt, Qs As Integer Dim Cryp As String = "" For Rt = 0 To Nombre - 1 Randomize() Qs = CInt(Int((Str.Length * Rnd()))) Do While Str.Contains(st) = True Randomize() st = Chr(CInt(Int((26 * Rnd()) + 65))) Loop Str = Str.Insert(Qs, st) Txt &= St Next For Rt = 0 To Txt.Length - 1 Qs = Str.IndexOf(Txt.ToCharArray(Rt, 1)) Emplac &= Format(Qs, "000") Next Str &= "." & Emplac For Rt = 0 To Str.Length - 1 Qs = Asc(Str.ToCharArray(Rt, 1)) Cryp &= Format(Qs, "000") Next Return Cryp End Function Function DeCrypte(ByVal MDPCrypte As String) As String Dim MDP As String = "" Dim St As String = "" Dim Str As String = "" Dim Rt As Integer = 0 For Rt = 0 To MDPCrypte.Length - 1 Step 3 St &= Chr(CInt(Val(MDPCrypte.ToCharArray(Rt, 3)))) Next MDP = Split(St, ".")(0) Str = Split(St, ".")(1) St = "" Dim Found As Boolean For i As Integer = 0 To MDP.Length - 1 Found = False For Rt = 0 To Str.Length - 1 Step 3 If i CInt(Val(Str.ToCharArray(Rt, 3))) Then Found True Next If Found = False Then St &= MDP.ToCharArray(i, 1) Next Return St End Function Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Le seul caractère interdit dans le mot de passe est "." (point) Dim Pass As String = ("oùÉpassémonpass") MsgBox("Mot de passe non crypté: " & Pass & " - Mot de passe crypté: " & Crypte(Pass)) MsgBox("En décryptant : " & DeCrypte("070111249201112097115115233109111110086074067089112097087073084115115046048049053048049052048050048048048048048049056048049051048049057048049050")) end sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionje ne dis JAMAIS que le nom/utilisateur saisi n'existe pas (si n'existe pas). je laisse forcer à saisir également le mot de passe. Et je ne lui dis JAMAIS non plus laquelle de ces deux saisies n'est pas la bonne.