SHARE
TWEET

Untitled

a guest Nov 23rd, 2012 81 Never
  1. var
  2.   Codec: TCodec;
  3.   CL: TCryptographicLibrary;
  4.   PlainStream: TStringStream;
  5.   CipherStream: TMemoryStream;
  6. begin
  7.   PlainStream := TStringStream.Create(Edit1.Text);
  8.   CipherStream := TMemoryStream.Create;
  9.  
  10.   CL := TCryptographicLibrary.Create(nil);
  11.   Codec := TCodec.Create(nil);
  12.   Codec.CryptoLibrary := CL;
  13.   Codec.ChainModeId := uTPLb_Constants.CBC_ProgId;
  14.   Codec.StreamCipherId := uTPLb_Constants.BlockCipher_ProgId;
  15.   Codec.BlockCipherId := Format(uTPLb_Constants.AES_ProgId, [256]);
  16.   Codec.Password := Edit3.Text;
  17.  
  18.   Codec.EncryptStream(PlainStream, CipherStream);
  19.   Codec.Burn;
  20.  
  21.   Memo1.Text := Stream_to_Base64(CipherStream);
  22.   Memo2.Clear;
  23.   Memo2.Lines.Add(Format('Size: %d bytes', [CipherStream.Size]));
  24.   Memo2.Lines.Add(Format('Original size: %d bytes', [PlainStream.Size]));
  25.  
  26.   Codec.Free;
  27.   CL.Free;
  28.   CipherStream.Free;
  29.   PlainStream.Free;
RAW Paste Data
Top