-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsample.dpr
50 lines (39 loc) · 1.01 KB
/
sample.dpr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
program aestest;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
System.Classes,
ElAES in 'ElAES.pas';
var inStream, outStream: TMemoryStream;
CryptKey: TAESKey256;
InitV: TAESBuffer;
i: Int32;
tmpBuf: array [0 .. 32] of Byte;
S: String;
begin
inStream := TMemoryStream.Create;
outStream := TMemoryStream.Create;
try
for i := 0 to 31 do
tmpBuf[i] := i;
inStream.Write(tmpBuf[0], 32);
// Generate CryptKey
for i := 1 to SizeOf(CryptKey) do
CryptKey[i - 1] := Byte(trunc((i * $D1) mod $FA));
// Generate InitV
for i := 1 to SizeOf(InitV) do
InitV[i - 1] := Byte(trunc((i * $B9) mod $CE));
// Encrypt inStream
EncryptAESStreamCBC(inStream, 0, CryptKey, InitV, outStream);
outStream.Position := 0;
outStream.Read(tmpBuf[0], 32);
for i := 0 to 31 do
S := S + IntToStr(tmpBuf[i]) + ' ';
WriteLn(S);
finally
inStream.Free;
outStream.Free;
end;
ReadLn;
end.