ble [Byte (T0 [0] shr 24)]; [3]: = (W0 xor ((W1 shl 8) or (W1 shr 24)) xor ((W2 shl 16) or (W2 shr 16 )) ((W3 shl 24) or (W3 shr 8))) xor Key [7];
// Последнийраундпреобразований: = LastInverseTable [Byte (T1 [0])]; W1: = LastInverseTable [Byte (T1 [3] shr 8)];: = LastInverseTable [Byte (T1 [2] shr 16)]; W3: = LastInverseTable [Byte (T1 [1] shr 24)]; [0]: = (W0 xor ((W1 shl 8) or (W1 shr 24)) xor ((W2 shl 16) or (W2 shr 16)) ((W3 shl 24) or (W3 shr 8))) xor Key [0];: = LastInverseTable [Byte (T1 [1])]; W1: = LastInverseTable [Byte (T1 [0] shr 8)];: = LastInverseTable [Byte (T1 [3] shr 16)]; W3: = LastInverseTable [Byte (T1 [2] shr 24)]; [1]: = (W0 xor ((W1 shl 8) or (W1 shr 24)) xor ((W2 shl 16) or (W2 shr 16)) ((W3 shl 24) or (W3 shr 8))) xor Key [1];: = LastInverseTable [Byte (T1 [2 ])]; W1: = LastInverseTable [Byte (T1 [1] shr 8)];: = LastInverseTable [Byte (T1 [0] shr 16)]; W3: = LastInverseTable [Byte (T1 [3] shr 24)] ; [2]: = (W0 xor ((W1 shl 8) or (W1 shr 24)) xor ((W2 shl 16) or (W2 shr 16)) ((W3 shl 24) or (W3 shr 8))) xor Key [2];: = LastInverseTable [Byte (T1 [3])]; W1: = LastInverseTable [Byte (T1 [2] shr 8)];: = LastInverseTable [Byte (T1 [1] shr 16)]; W3: = LastInverseTable [Byte (T1 [0] shr 24)]; [3]: = (W0 xor ((W1 shl 8) or (W1 shr 24)) xor ((W2 shl 16) or (W2 shr 16) ) ((W3 shl 24) or (W3 shr 8))) xor Key [3];
// Кінцеве перетворення (@ OutBuf [0]) ^: = T0 [0]; PLongWord (@ OutBuf [4]) ^: = T0 [1];
PLongWord (@ OutBuf [8]) ^: = T0 [2]; PLongWord (@ OutBuf [12]) ^: = T0 [3];
end;
// Спочатку ключ перекладається до розширеного
procedure EncryptAESStreamECB (Source: TStream; Count: cardinal; Key: TAESKey128; Dest: TStream);: TAESExpandedKey128; (Key, ExpandedKey);
// Виклик з цієї процедури процедури шіфорованія з розширеним ключем
EncryptAESStreamECB (Source, Count, ExpandedKey, Dest);;
// ШифрованиепотокаEncryptAESStreamECB (Source: TStream; Count: cardinal; ExpandedKey: TAESExpandedKey128; Dest: TStream);
var, TempOut: TAESBuffer;// Розмір буферів зчитування і запису
Done: cardinal;: TStringStream;: integer;: = TStringStream. Create (''); Count = 0 then. Position: = 0;// Указательвначалопотока: = Source. Size;// Визначення поточного розміру потоку
endCount: = Min (Count, Source. Size - Source. Position); Count = 0 then exit; Count> = SizeOf (TAESBuffer) do: = Source. Read (TempIn, SizeOf (TempIn));// СчітиваемданниеізпотокаDone
// Висновок вхідного і вихідного блоків
FmStop. EditIn. Text: = IntToHex (TempIn [0], 2) + IntToHex (TempIn [1], 2) + (TempIn [2], 2) + I...