这组VB6加密功能可以被破解吗?

CJ7*_*CJ7 2 vb6 encryption cryptography

 Public Function EncryptString(theString As String, TheKey As String) As String
    Dim X As Long
    Dim eKey As Byte, eChr As Byte, oChr As Byte, tmp$
    For i = 1 To Len(TheKey)
         'generate a key
          eKey = Asc(Mid$(TheKey, i, 1)) Xor eKey
    Next

    'reset random function
    Rnd -1
    'initilize our key as the random seed
    Randomize eKey
    'generate a pseudo old char
    oChr = Int(Rnd * 256)
    'start encryption
    For X = 1 To Len(theString)
        pp = pp + 1
        If pp > Len(TheKey) Then pp = 1
        eChr = Asc(Mid$(theString, X, 1)) Xor _
                   Int(Rnd * 256) Xor Asc(Mid$(TheKey, pp, 1)) Xor oChr
        tmp$ = tmp$ & Chr(eChr)
        oChr = eChr
    Next
    EncryptString = AsctoHex(tmp$)    

End Function


Public Function DecryptString(theString As String, TheKey As String) As String

Dim X As Long
Dim eKey As Byte, eChr As Byte, oChr As Byte, tmp$
For i = 1 To Len(TheKey)
     'generate a key
     eKey = Asc(Mid$(TheKey, i, 1)) Xor eKey
Next
'reset random function
Rnd -1
'initilize our key as the random seed
Randomize eKey
'generate a pseudo old char
oChr = Int(Rnd * 256)
'start decryption
tmp$ = HexToAsc(theString)
    DecryptString = ""
    For X = 1 To Len(tmp$)
    pp = pp + 1
    If pp > Len(TheKey) Then pp = 1
    If X > 1 Then oChr = Asc(Mid$(tmp$, X - 1, 1))
    eChr = Asc(Mid$(tmp$, X, 1)) Xor Int(Rnd * 256) Xor _
           Asc(Mid$(TheKey, pp, 1)) Xor oChr
        DecryptString = DecryptString & Chr$(eChr)
Next

End Function


Private Function AsctoHex(ByVal astr As String)

For X = 1 To Len(astr)
hc = Hex$(Asc(Mid$(astr, X, 1)))
nstr = nstr & String(2 - Len(hc), "0") & hc
Next
AsctoHex = nstr

End Function
Run Code Online (Sandbox Code Playgroud)

Ole*_*ksi 6

您不应该尝试自己实现这样的加密.很难做到正确,并且很容易意外地构建漏洞.

找到已经证明可行且经过大量测试的现有解决方案会更容易,更安全.可能是一个更好的解决方案.