Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 23rd, 2012  |  syntax: Delphi  |  size: 0.87 KB  |  views: 51  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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;
clone this paste RAW Paste Data