I'm tinkering with some encryption stuff that doesn't exactly work at the moment, and I just can't figure out what the problem is.
Here's what should happen: Program 1 should write an AES-encrypted file, Program 2 should decrypt that file.
Program 1:
Code: Select all
Structure Vector_struc
Byte.a[32]
EndStructure
Filepath$="C:\test.file"
Password$="MyAwesomePassword"
a$=""
a$=a$+"I am a string "
a$=a$+"-------------------------------------------------------------------------------------------"
a$=a$+"-------------------------------------------------------------------------------------------"
a$=a$+"-------------------------------------------------------------------------------------------"
a$=a$+"-------------------------------------------------------------------------------------------"
String$=a$
*vector.Vector_struc
VectorSize=32
bit=256
*Vector= AllocateMemory(VectorSize)
RandomSeed(562642)
For i=0 To VectorSize-1
*Vector\Byte[i] = Random(255)
Next
File=CreateFile(#PB_Any, Filepath$)
*AESEncoded = AllocateMemory(Len(String$))
AESEncoder(@String$,*AESEncoded,Len(String$),@Password$,Bit,*Vector)
WriteData(File,*AESEncoded,Len(String$))
CloseFile(File)
FreeMemory(*AESEncoded)
Code: Select all
Structure Vector_struc
Byte.a[32]
EndStructure
Filepath$="C:\test.file"
Password$="MyAwesomePassword"
*vector.Vector_struc
VectorSize=32
bit=256
*Vector= AllocateMemory(VectorSize)
RandomSeed(562642)
For i=0 To VectorSize-1
*Vector\Byte[i] = Random(255)
Next
File=ReadFile(#PB_Any, Filepath$)
Size=Lof(File)
*AESEncoded=AllocateMemory(Size)
ReadData(File,*AESEncoded,Size)
CloseFile(File)
*AESDecoded = AllocateMemory(Size)
AESDecoder(*AESEncoded,*AESDecoded,Size,@Password$,Bit,*Vector)
Result$ = PeekS(*AESDecoded,Size)
FreeMemory(*AESEncoded)
FreeMemory(*AESDecoded)
Debug Result$
