Bonjour à tous,

Voilà, j’essaie de crypter des données (une suite de textes, dates, temps... séparés par "#". NB : mes textes peuvent contenir des "retour chariot") contenu dans un fichier TXT en une seule ligne. Je lis donc le contenu de mon fichier avec un Je crypte mon fichier avec ce code trouvé sur le Net :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Public Function Crypt(ByVal strChaine As String, blnCryptage As Boolean) As String
'Utilisation:
'- Cryptage --> Crypt("Chaine a crypter", true)
'- Decryptage -->Crypt("Chaine a decrypter", false)
    Dim I As Integer, J As Integer, K As Integer
    Dim strCryptKey As String, strLettre As String, strKeyLettre As String
    Dim intLettre As Long, intKeyLettre As Long, strResultat As String
 
    If strChaine = "" Then
        Crypt = ""
        Exit Function
    End If
 
    strCryptKey = "Clé secondaire de cryptage"
 
    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
Mais quand je relis ce fichier, avec un contenu crypté, je me suis aperçu qu'il contenait plusieurs lignes...

Je ne peut plus le lire avec un "Line Input"... Le décryptage ne se fait pas correctement.

Quelqu'un aurait-il une solution à mon problème ou, comment lire l'intégralité d'un fichier en une seule variable (chaine$) ?

Bonne journée à tous...

Denis...