RE: Tool to encrypt or decrypt log files
Hi,
I'm trying to write a funtion using visual basic 6 and the CryptDecrypt call always returns 0
Can anyone tell me what am I doing wrong?
here is the code:
'read the full encrypted file and convert it to string
F = App.Path & "\encryptedfile.ple"
FN = FreeFile
dlen = FileLen(F)
ReDim data(dlen)
Open F For Binary As FN
Get #FN, , data
Close FN
For pos = 0 To dlen
Stemp = Stemp & Chr(data(pos))
Next pos
'set the correct password (I have encrypted using this pwd)
'no password scramble needed as al the chars are the same.
pwd = "bbbb"
'api calls the constants are expressed as decimal.. it should work..
Rst = CryptAcquireContext(hProv, "MessengerPlusEncryptProvider", "Microsoft Enhanced Cryptographic Provider v1.0", 1, 0)
Rst = CryptCreateHash(hProv, 32771, 0, 0, hHash)
Rst = CryptHashData(hHash, pwd, l, 0)
Rst = CryptDeriveKey(hProv, 26625, hHash, 8388608, Hkey)
Rst = CryptDecrypt(Hkey, 0, 1, 0, Stemp, Len(Stemp))
the last call returns "0" and the stemp content is not decrypted..
thank you!!!!
This post was edited on 03-09-2011 at 06:10 PM by willy469.
|