- Private Function Crypt(ByVal strChaine As String, blnCryptage As Boolean) As String
- Dim I, J, K As Integer
- Dim strCryptKey As String
- Dim strLettre As String
- Dim strKeyLettre As String
- Dim intLettre As Long
- Dim intKeyLettre As Long
- Dim strResultat As String
-
- If strChaine = "" Then
- Crypt = ""
- Exit Function
- End If
-
- strCryptKey = "chiffrement de Vigenere"
-
- For K = 0 To 10 Step 1
- strResultat = ""
-
- For I = 1 To Len(strChaine) Step 1
- strLettre = Mid(strChaine, I, 1)
- J = I
- Do While J > Len(strCryptKey)
- J = J - Len(strCryptKey)
- Loop
- strKeyLettre = Mid(strCryptKey, J, 1)
- intLettre = Asc(strLettre)
- intKeyLettre = Asc(strKeyLettre)
-
- If blnCryptage = True Then
- intLettre = intLettre + (intKeyLettre * Len(strChaine))
- Else
- intLettre = intLettre - (intKeyLettre * Len(strChaine))
- End If
-
- Do While intLettre > 255
- intLettre = intLettre - 255
- Loop
- Do While intLettre < 0
- intLettre = intLettre + 255
- Loop
- strResultat = strResultat & Chr(intLettre)
- Next I
-
- strChaine = strResultat
- Next K
-
- Crypt = strResultat
- End Function
Private Function Crypt(ByVal strChaine As String, blnCryptage As Boolean) As String
Dim I, J, K As Integer
Dim strCryptKey As String
Dim strLettre As String
Dim strKeyLettre As String
Dim intLettre As Long
Dim intKeyLettre As Long
Dim strResultat As String
If strChaine = "" Then
Crypt = ""
Exit Function
End If
strCryptKey = "chiffrement de Vigenere"
For K = 0 To 10 Step 1
strResultat = ""
For I = 1 To Len(strChaine) Step 1
strLettre = Mid(strChaine, I, 1)
J = I
Do While J > Len(strCryptKey)
J = J - Len(strCryptKey)
Loop
strKeyLettre = Mid(strCryptKey, J, 1)
intLettre = Asc(strLettre)
intKeyLettre = Asc(strKeyLettre)
If blnCryptage = True Then
intLettre = intLettre + (intKeyLettre * Len(strChaine))
Else
intLettre = intLettre - (intKeyLettre * Len(strChaine))
End If
Do While intLettre > 255
intLettre = intLettre - 255
Loop
Do While intLettre < 0
intLettre = intLettre + 255
Loop
strResultat = strResultat & Chr(intLettre)
Next I
strChaine = strResultat
Next K
Crypt = strResultat
End Function