d7到d2009对应的 string=ansistringpchar=ansichar procedure EncryptAESStreamECB(Source: TStream; Count: cardinal; const ExpandedKey: TAESExpandedKey128; Dest: TStream); var TempIn, TempOut: TAESBuffer; Done: cardinal; ss:AnsiString; i,j:Integer; begin ss:=''; if Count = 0 then begin Source.Position := 0; Count := Source.Size; end else Count := Min(Count, Source.Size - Source.Position); if Count = 0 then exit; while Count >= SizeOf(TAESBuffer) do begin Done := Source.Read(TempIn, SizeOf(TempIn)); if Done < SizeOf(TempIn) then raise EStreamError.Create(SReadError); EncryptAES(TempIn, ExpandedKey, TempOut); for I := 0 to 15 do begin ss:=ss+ IntToHex( tempout,2); end; Done := dest.Write(tempout, SizeOf(tempout)); if Done < SizeOf(tempout) then raise EStreamError.Create(SWriteError); Dec(Count, SizeOf(TAESBuffer)); end; if Count > 0 then begin Done := Source.Read(TempIn, Count); if Done < Count then raise EStreamError.Create(SReadError); FillChar(TempIn[Count], SizeOf(TempIn) - Count, 0); EncryptAES(TempIn, ExpandedKey, TempOut); for j := 0 to 15 do begin ss:=ss+ IntToHex( tempout[j],2); end; Done := dest.Write(Tempout, SizeOf(tempout)); if Done < SizeOf(TempOut) then raise EStreamError.Create(SWriteError); end; Dest.Free; Dest:= TStringStream.Create(ss); end;