Et la version VBA, je ne sais plus de qui j'avais récupéré ça à l'époque... Peut être sur le forum
Function ChiffrerTexte(ByVal texte As String, ByVal cle As String) As String
Dim alphabet As String
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
Dim i As Long, posTexte As Long, posCle As Long
Dim resultat As String
Dim cTexte As String, cCle As String
For i = 1 To Len(texte)
cTexte = Mid(texte, i, 1)
cCle = Mid(cle, ((i - 1) Mod Len(cle)) + 1, 1)
posTexte = InStr(1, alphabet, cTexte, vbBinaryCompare)
posCle = InStr(1, alphabet, cCle, vbBinaryCompare)
If posTexte > 0 And posCle > 0 Then
resultat = resultat & Mid(alphabet, _
((posTexte + posCle - 2) Mod Len(alphabet)) + 1, 1)
Else
resultat = resultat & cTexte
End If
Next i
ChiffrerTexte = resultat
End Function
Function DechiffrerTexte(ByVal texte As String, ByVal cle As String) As String
Dim alphabet As String
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
Dim i As Long, posTexte As Long, posCle As Long
Dim resultat As String
Dim cTexte As String, cCle As String
For i = 1 To Len(texte)
cTexte = Mid(texte, i, 1)
cCle = Mid(cle, ((i - 1) Mod Len(cle)) + 1, 1)
posTexte = InStr(1, alphabet, cTexte, vbBinaryCompare)
posCle = InStr(1, alphabet, cCle, vbBinaryCompare)
If posTexte > 0 And posCle > 0 Then
resultat = resultat & Mid(alphabet, _
((posTexte - posCle + Len(alphabet)) Mod Len(alphabet)) + 1, 1)
Else
resultat = resultat & cTexte
End If
Next i
DechiffrerTexte = resultat
End Function
@+