W poniedzia³ek 19-kwietnia-2004 o godzinie 16:22:30 Amstel napisa³/a
Bonjour, Je recherche désespérément une fonction permettant en VB6 d'encoder un texte en base64
Est-ce que quelqu'un aurait vu cela quelquepart ???
www.amsoft.com.pl/downloads/base64.dll
C'est un ActiveX Dll
-- Pozdrawiam Adam Pietrasiewicz
ng
Salut,
Voici les fonctions que j'ai toujours utilsé sont problème (rapide et tout et tout ;)) :
Public Function Base64Encode$(S$) Dim b() As Byte, Out() As Byte, i&, j&, L&, Enc() As Byte If Len(S) = 0 Then Exit Function Enc StrConv("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", vbFromUnicode) L = Len(S): b = StrConv(S, vbFromUnicode) ReDim Preserve b(0 To (UBound(b) 3) * 3 + 2) ReDim Preserve Out(0 To (UBound(b) 3) * 4 + 3) For i = 0 To UBound(b) - 1 Step 3 Out(j) = Enc(b(i) 4): j = j + 1 Out(j) = Enc((b(i + 1) 16) Or (b(i) And 3) * 16): j = j + 1 Out(j) = Enc((b(i + 2) 64) Or (b(i + 1) And 15) * 4): j = j + 1 Out(j) = Enc(b(i + 2) And 63): j = j + 1 Next i For i = 1 To i - L: Out(UBound(Out) - i + 1) = 61: Next i Base64Encode = StrConv(Out, vbUnicode) End Function
Public Function Base64Decode$(S$) Dim b() As Byte, Out() As Byte, i&, j&, L&, Enc() As Byte, Dec(0 To 255) As Byte If Len(S) = 0 Then Exit Function Enc StrConv("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", vbFromUnicode) For i = 0 To 255: Dec(i) = 64: Next For i = 0 To 63: Dec(Enc(i)) = i: Next L = Len(S): b = StrConv(S, vbFromUnicode) ReDim Preserve Out(0 To (L 4) * 3 - 1) For i = 0 To UBound(b) Step 4 Out(j) = (Dec(b(i)) * 4) Or (Dec(b(i + 1)) 16): j = j + 1 Out(j) = (Dec(b(i + 1)) And 15) * 16 Or (Dec(b(i + 2)) 4): j = j + 1 Out(j) = (Dec(b(i + 2)) And 3) * 64 Or Dec(b(i + 3)): j = j + 1 Next i If b(L - 2) = 61 Then j = 2 Else If b(L - 1) = 61 Then j = 1 Else j = 0 ReDim Preserve Out(0 To UBound(Out) - j) Base64Decode = StrConv(Out, vbUnicode) End Function
Bonjour, Je recherche désespérément une fonction permettant en VB6 d'encoder un texte en base64
Est-ce que quelqu'un aurait vu cela quelquepart ???
Merci de votre aide Jean-Marc
Salut,
Voici les fonctions que j'ai toujours utilsé sont problème (rapide et tout
et tout ;)) :
Public Function Base64Encode$(S$)
Dim b() As Byte, Out() As Byte, i&, j&, L&, Enc() As Byte
If Len(S) = 0 Then Exit Function
Enc StrConv("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
vbFromUnicode)
L = Len(S): b = StrConv(S, vbFromUnicode)
ReDim Preserve b(0 To (UBound(b) 3) * 3 + 2)
ReDim Preserve Out(0 To (UBound(b) 3) * 4 + 3)
For i = 0 To UBound(b) - 1 Step 3
Out(j) = Enc(b(i) 4): j = j + 1
Out(j) = Enc((b(i + 1) 16) Or (b(i) And 3) * 16): j = j + 1
Out(j) = Enc((b(i + 2) 64) Or (b(i + 1) And 15) * 4): j = j + 1
Out(j) = Enc(b(i + 2) And 63): j = j + 1
Next i
For i = 1 To i - L: Out(UBound(Out) - i + 1) = 61: Next i
Base64Encode = StrConv(Out, vbUnicode)
End Function
Public Function Base64Decode$(S$)
Dim b() As Byte, Out() As Byte, i&, j&, L&, Enc() As Byte, Dec(0 To 255)
As Byte
If Len(S) = 0 Then Exit Function
Enc StrConv("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
vbFromUnicode)
For i = 0 To 255: Dec(i) = 64: Next
For i = 0 To 63: Dec(Enc(i)) = i: Next
L = Len(S): b = StrConv(S, vbFromUnicode)
ReDim Preserve Out(0 To (L 4) * 3 - 1)
For i = 0 To UBound(b) Step 4
Out(j) = (Dec(b(i)) * 4) Or (Dec(b(i + 1)) 16): j = j + 1
Out(j) = (Dec(b(i + 1)) And 15) * 16 Or (Dec(b(i + 2)) 4): j = j + 1
Out(j) = (Dec(b(i + 2)) And 3) * 64 Or Dec(b(i + 3)): j = j + 1
Next i
If b(L - 2) = 61 Then j = 2 Else If b(L - 1) = 61 Then j = 1 Else j = 0
ReDim Preserve Out(0 To UBound(Out) - j)
Base64Decode = StrConv(Out, vbUnicode)
End Function
--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/
http://apisvb.europe.webmatrixhosting.net/
Amstel <anonymous@discussions.microsoft.com> a écrit :
Bonjour,
Je recherche désespérément une fonction permettant en VB6
d'encoder un texte en base64
Est-ce que quelqu'un aurait vu cela quelquepart ???
Voici les fonctions que j'ai toujours utilsé sont problème (rapide et tout et tout ;)) :
Public Function Base64Encode$(S$) Dim b() As Byte, Out() As Byte, i&, j&, L&, Enc() As Byte If Len(S) = 0 Then Exit Function Enc StrConv("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", vbFromUnicode) L = Len(S): b = StrConv(S, vbFromUnicode) ReDim Preserve b(0 To (UBound(b) 3) * 3 + 2) ReDim Preserve Out(0 To (UBound(b) 3) * 4 + 3) For i = 0 To UBound(b) - 1 Step 3 Out(j) = Enc(b(i) 4): j = j + 1 Out(j) = Enc((b(i + 1) 16) Or (b(i) And 3) * 16): j = j + 1 Out(j) = Enc((b(i + 2) 64) Or (b(i + 1) And 15) * 4): j = j + 1 Out(j) = Enc(b(i + 2) And 63): j = j + 1 Next i For i = 1 To i - L: Out(UBound(Out) - i + 1) = 61: Next i Base64Encode = StrConv(Out, vbUnicode) End Function
Public Function Base64Decode$(S$) Dim b() As Byte, Out() As Byte, i&, j&, L&, Enc() As Byte, Dec(0 To 255) As Byte If Len(S) = 0 Then Exit Function Enc StrConv("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", vbFromUnicode) For i = 0 To 255: Dec(i) = 64: Next For i = 0 To 63: Dec(Enc(i)) = i: Next L = Len(S): b = StrConv(S, vbFromUnicode) ReDim Preserve Out(0 To (L 4) * 3 - 1) For i = 0 To UBound(b) Step 4 Out(j) = (Dec(b(i)) * 4) Or (Dec(b(i + 1)) 16): j = j + 1 Out(j) = (Dec(b(i + 1)) And 15) * 16 Or (Dec(b(i + 2)) 4): j = j + 1 Out(j) = (Dec(b(i + 2)) And 3) * 64 Or Dec(b(i + 3)): j = j + 1 Next i If b(L - 2) = 61 Then j = 2 Else If b(L - 1) = 61 Then j = 1 Else j = 0 ReDim Preserve Out(0 To UBound(Out) - j) Base64Decode = StrConv(Out, vbUnicode) End Function