Home > Back-end >  Vb encryption function into the Delphi for help
Vb encryption function into the Delphi for help

Time:10-01

 Attribute VB_Name="Module1" 
The Public Function Encode (ByVal s As String) As String 'encryption
If Len (s)=0 Then the Exit Function
Dim buff () As Byte
Buff=StrConv (s, vbFromUnicode)
Dim As Long I
Dim j As Byte
Dim k As Byte, m As Byte
Dim MSTR As String
'encrypted MSTR="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz" contains characters
Dim outs As String
I=UBound (buff) + 1
Outs=Space (2 * I)
Dim temps As String
For I=0 To UBound (buff)
Randomize the Time
J=CByte (5 * (math.h Rnd ()) + 0) 'biggest generated random number is only five, can't again big, big again, will use a byte
Buff (I)=buff (I) Xor j
K=buff (I) the Mod Len (MSTR)
M=buff (I) \ Len (MSTR)
M=m * 2 ^ 3 + j
Temps=Mid (MSTR, k + 1, 1) + Mid (MSTR, m + 1, 1)
Mid (outs, 2 * I + 1, 2)=temps
Next
Encode=outs
End the Function
The Public Function Decode (ByVal s As String) As String 'decryption
On Error GoTo myERR
Dim As Long I
Dim j As Byte
Dim k As Byte
Dim m As Byte
Dim MSTR As String
MSTR="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"
Dim t1 As String, t2 As String
Dim buff () As Byte
Dim n As Long
N=0
For I=1 To Len (s) Step 2
T1=Mid (s, I, 1)
T2=Mid (s, I + 1, 1)
K=InStr (1, MSTR, t1) - 1
M=InStr (1, MSTR, t2) - 1
J=2 ^ 3 m \
M=m - j * 2 ^ 3
ReDim Preserve buff (n)
Buff (n)=j * Len (MSTR) + k
Buff (n)=buff (n) Xor m
N=n + 1
Next
Decode=StrConv (buff, vbUnicode)
The Exit Function
MyERR:
Decode=""
End the Function

Above is found online vb string encryption function, used in a small program, how do I add the vb decryption function into Delphi?
Only 20 points, all give up
  • Related