marcuslee
01-12-2009, 02:56
I've been trying to get FILE and CRYPTO to work together. I can get encrypted data to be inserted into a RANDOM file, but when I retrieve it, the message is both encrypted and decrypted. It is kinda strange.
Here's the code:
Uses "File", "Crypto"
Type Record
Message As String * 50
Alt As String *50
End Type
Dim Save As Record
Dim GetContents As Record
Dim Decrypt As Record
Dim FileName As String = APP_SourcePath & "Records.DAT"
Dim f As DWord
Dim password As String = "password"
FILE_Kill(FileName)
f = FILE_Open(FileName, "random", SIZEOF(Record))
Save.Message = iCrypto_EncryptRC4("Here is the first message.", password)
Save.Alt = iCrypto_EncryptRC4("Here is the first alternate.", password)
FILE_PutR(f, 1, Save)
Save.Message = iCrypto_EncryptRC4("Here is the second message.", password)
Save.Alt = iCrypto_EncryptRC4("Here is the second alternate.", password)
FILE_PutR(f, 2, Save)
FILE_GetR(f, 1, GetContents)
Decrypt.Message = iCrypto_DecryptRC4(GetContents.Message, password)
Decrypt.Alt = iCrypto_DecryptRC4(GetContents.Alt, password)
MsgBox 0, Decrypt.Message & Chr$(13) & Decrypt.Alt
Anyone have any ideas of what I am doing wrong?
Mark :violent:
Here's the code:
Uses "File", "Crypto"
Type Record
Message As String * 50
Alt As String *50
End Type
Dim Save As Record
Dim GetContents As Record
Dim Decrypt As Record
Dim FileName As String = APP_SourcePath & "Records.DAT"
Dim f As DWord
Dim password As String = "password"
FILE_Kill(FileName)
f = FILE_Open(FileName, "random", SIZEOF(Record))
Save.Message = iCrypto_EncryptRC4("Here is the first message.", password)
Save.Alt = iCrypto_EncryptRC4("Here is the first alternate.", password)
FILE_PutR(f, 1, Save)
Save.Message = iCrypto_EncryptRC4("Here is the second message.", password)
Save.Alt = iCrypto_EncryptRC4("Here is the second alternate.", password)
FILE_PutR(f, 2, Save)
FILE_GetR(f, 1, GetContents)
Decrypt.Message = iCrypto_DecryptRC4(GetContents.Message, password)
Decrypt.Alt = iCrypto_DecryptRC4(GetContents.Alt, password)
MsgBox 0, Decrypt.Message & Chr$(13) & Decrypt.Alt
Anyone have any ideas of what I am doing wrong?
Mark :violent: