Es sind aber noch keine Sicherheitsabfragen eingebaut ob auch wirklich die Datei ohne Fehler verschlüsselt bzw. Entschlüsselt wurde.
Wer mag kann das noch einbauen und den Code hier posten

Code: Alles auswählen
#Bytes = 524288 ; Datei in 512 kb Stückchen einlesen
Procedure AES_Crypt(file$, pass$, bits.l=128)
filesize.q = FileSize(file$)
If filesize.q > 0
rounds.l = Int(filesize.q/#Bytes)
rest.l = filesize.q-(rounds.l*#Bytes)
*Input = AllocateMemory(#Bytes)
*Output = AllocateMemory(#Bytes)
*Input2 = AllocateMemory(rest.l)
*Output2 = AllocateMemory(rest.l)
If OpenFile(0, file$)
For i=0 To rounds.l-1
FileSeek(0, #Bytes*i)
gelesen.l = ReadData(0, *Input, #Bytes)
If AESEncoder(*Input, *Output, #Bytes, @pass$, bits.l, 0, #PB_Cipher_ECB)
FileSeek(0, #Bytes*i)
WriteData(0,*Output, #Bytes)
EndIf
Next
FileSeek(0, Lof(0)-rest.l)
gelesen.l = ReadData(0, *Input2, rest.l)
If AESEncoder(*Input2, *Output2, rest.l, @pass$, bits.l, 0, #PB_Cipher_ECB)
FileSeek(0, Lof(0)-rest.l)
WriteData(0,*Output2, rest.l)
EndIf
CloseFile(0)
EndIf
FreeMemory(*Input)
FreeMemory(*Input2)
FreeMemory(*Output)
FreeMemory(*Output2)
EndIf
ProcedureReturn 1
EndProcedure
Procedure AES_Decrypt(file$, pass$, bits.l=128)
filesize.q = FileSize(file$)
If filesize.q > 0
rounds.l = Int(filesize.q/#Bytes)
rest.l = filesize.q-(rounds.l*#Bytes)
*Input = AllocateMemory(#Bytes)
*Output = AllocateMemory(#Bytes)
*Input2 = AllocateMemory(rest.l)
*Output2 = AllocateMemory(rest.l)
If OpenFile(0, file$)
For i=0 To rounds.l-1
FileSeek(0, #Bytes*i)
gelesen.l = ReadData(0, *Input, #Bytes)
If AESDecoder(*Input, *Output, #Bytes, @pass$, bits.l, 0, #PB_Cipher_ECB)
FileSeek(0, #Bytes*i)
WriteData(0,*Output, #Bytes)
EndIf
Next
FileSeek(0, Lof(0)-rest.l)
gelesen.l = ReadData(0, *Input2, rest.l)
If AESDecoder(*Input2, *Output2, rest.l, @pass$, bits.l, 0, #PB_Cipher_ECB)
FileSeek(0, Lof(0)-rest.l)
WriteData(0,*Output2, rest.l)
EndIf
CloseFile(0)
EndIf
FreeMemory(*Input)
FreeMemory(*Input2)
FreeMemory(*Output)
FreeMemory(*Output2)
EndIf
ProcedureReturn 1
EndProcedure