EldoS | Feel safer!

Software components for data protection, secure storage and transfer

How to encrypt AES 128 ECB with key

Also by EldoS: CallbackDisk
Create virtual disks backed by memory or custom location, expose disk images as disks and more.
#37413
Posted: 08/09/2016 14:55:27
by Bremen Sistemas (Basic support level)
Joined: 08/20/2012
Posts: 17

Code
procedure TForm1.Button4Click(Sender: TObject);
var
  Crypto: TElAESSymmetricCrypto;
  keyM: TElSymmetricKeyMaterial;
  KeyBuf,InBuf,OutBuf: ByteArray;
  OutSize: integer;
  IV : ByteArray;

  mykey: string;
begin
  mykey := 'hFPcpNFQ8JQhmJ/idIngQg==';        // normal
  //mykey := 'aEZQY3BORlE4SlFobUovaWRJbmdRZz09';  // base64

  Crypto         := TElAESSymmetricCrypto.Create(SB_ALGORITHM_CNT_AES128, cmECB);
  //Crypto.Padding := cpPKCS5;

  keyM   := TElSymmetricKeyMaterial.Create;

  try
    SetLength(IV, 16);
    IV:= SBUtils.BytesOfString(Copy(Edit1.Text,1,16));
    Key.IV := IV;
    KeyBuf := SBUtils.BytesOfString(Edit1.Text);
    Key.Key:= KeyBuf;
      //key.Generate(128);
    aes.Padding := cpNone;
    aes.KeyMaterial := Key;

   // aes.Mode :=

    InBuf := SBUtils.BytesOfString(Edit2.Text);
    OutSize := 0;
    aes.Encrypt(@InBuf[0], Length(InBuf), nil, OutSize);
    SetLength(OutBuf, OutSize);
    aes.Encrypt(@InBuf[0], Length(InBuf), @OutBuf[0], OutSize);
    SetLength(OutBuf, OutSize);
    // convert binary output to Base64 to make it readable
    Memo1.Clear;
    Memo1.Text := SBEncoding.Base64EncodeArray(OutBuf, false);
  finally
    FreeAndNil(Crypto);
    FreeAndNil(keyM);
  end;
end;


How to encrypt AES 128, with 16bits, if my "mykey" is size 24 ?
Tkz
#37414
Posted: 08/09/2016 15:07:50
by Eugene Mayevski (EldoS Corp.)

Technical Support is provided to customers with the linked Support Access Ticket. You will find your Support Access Ticket together with all the details about how to use it in the registration e-mail that we’ve sent to you upon the purchase. The procedure of linking the Support Access Ticket is described in the registration e-mail as well.

I am afraid that without the Support Access Ticket linked we won't be able to assist you. Thank you for understanding.


Sincerely yours
Eugene Mayevski

Reply

Statistics

Topic viewed 389 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!