Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Help with AES!!!

Posted on 2007-03-27
13
482 Views
Last Modified: 2010-04-05
Hi,
I want a component (better if was open source or free) that do the AES encryption.
Besat Regards.
0
Comment
Question by:engayman01
  • 7
  • 5
13 Comments
 
LVL 21

Expert Comment

by:ziolko
ID: 18799193
0
 
LVL 28

Expert Comment

by:2266180
ID: 18799303
or the long dissapeared aldos implementation: http://www.ciuly.com/delphi/basicSecurity/cryptography/aes/index.html
0
 
LVL 1

Author Comment

by:engayman01
ID: 18806072
For ciuly,
I want to use the same key for another application, is there a way to use a hex key?
ie : i want your methods for decrypt and encrypt to take a hex key and i parse it as a string.
Regards.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 28

Expert Comment

by:2266180
ID: 18806081
I'm not sure I understand your question. a hex key, like 0e3a579bc ? if so, that is just a subset of the possible key characters so of course it can be done. but since you are saying hex .. I am thinking maybe you want to do something else, so better just give a clear example ;)
0
 
LVL 1

Author Comment

by:engayman01
ID: 18806365
If i have a key 'c03de8d73d1c03de8d73d1c03de8d73d1' and i want to use it in your procedure as
EncryptAESStreamECB( Source, 0, 'c03de8d73d1c03de8d73d1c03de8d73d1', Dest );
How i can do it??
Regards.
0
 
LVL 28

Expert Comment

by:2266180
ID: 18806393
you actually need to put the key in a (for example) TAESKey128 like:

var key128:TAESKey128;
begin
  FillChar(Key128, SizeOf(Key128), 0);
  Move(PChar(key)^, Key128, Min(SizeOf(Key128), Length(key)));

  EncryptAESStreamECB(source, 0, key128, dest);  
end;

dest will hold the crypted data.

to crypt/decrypt a string and return a (binary) sting, use the following functions:

function AES_crypt(data, key: string): string;
var key128:TAESKey128;
    count:integer;
    source, dest:TStringStream;
begin
  source:=TStringStream.Create(data);
  dest:=TStringStream.Create('');

  source.WriteString(data);
  source.Position:=0;
  count:=source.Size;
  dest.Write(count, sizeof(count));

  FillChar(Key128, SizeOf(Key128), 0);
  Move(PChar(key)^, Key128, Min(SizeOf(Key128), Length(key)));

  EncryptAESStreamECB(source, 0, key128, dest);

  dest.Position:=0;
  result:=dest.ReadString(dest.size);

  dest.Free;
  source.Free;
end;

function AES_decrypt(data, key: string): string;
var key128:TAESKey128;
    count:integer;
    source, dest:TStringStream;
begin
  source:=TStringStream.Create(data);
  dest:=TStringStream.Create('');

  source.Position:=0;
  source.ReadBuffer(count, sizeof(count));

  FillChar(Key128, SizeOf(Key128), 0);
  Move(PChar(key)^, Key128, Min(SizeOf(Key128), Length(key)));

  DecryptAESStreamECB(source, Source.Size-source.Position, key128, dest);

  dest.Size:=count;
  dest.Position:=0;
  result:=dest.ReadString(dest.size);

  dest.Free;
  source.Free;
end;

the above code was adapted from the demo in the zip I gave you.
0
 
LVL 1

Author Comment

by:engayman01
ID: 18806606
I use it but the cipher output is differ from my another application that use AES with the same key!!
My another application implemented in java and use a standard AES from SUN.
What do you think the problem is??
Regards
0
 
LVL 1

Author Comment

by:engayman01
ID: 18806631
Is there a way to convert the string into array of bytes?
Thanks.
0
 
LVL 28

Accepted Solution

by:
2266180 earned 50 total points
ID: 18806692
well, I gave you an example for a 128 bit key. tehre is also a 192 bit and a 256 bit key ... which one does your java program use?

easiest way of getting an array of bytes is to modify the function to return an array of bytes and read that from the stream directly.

also, since you didn't cleared up the hex part: is the hex key a binary key, displayed as hex or is it indeed a simple hex string as it is? because if teh key is a binary key, then you need to convert the hex to binary first and then use it.
0
 
LVL 28

Expert Comment

by:2266180
ID: 18953677
why a B grade? I do not agree with this resolution. I have given you a good solution but you didn't give me enough information so that I can help you.
I'd like you to reconsider.
0
 
LVL 1

Author Comment

by:engayman01
ID: 18954113
I give you a B grade because i use an AES algorithm standard from SUN 128 bit but the it different from your work as i was explain so my problem doesn't solved
0
 
LVL 28

Expert Comment

by:2266180
ID: 18954624
your problem is not solved because you failed to communicate with me that information. I asked you questions and you didn't answer. it is not my fault that you didn't asnwer so that I can help.
If we cannot get to an agreement, I am in favour of getting a moderator to assist on the issue.
0
 
LVL 28

Expert Comment

by:2266180
ID: 20390806
Here is how things *should work* on EE:

Any expert MUST have the chance to earn an A grade. Just because you are the one that did not give sufficient information or asked for clarifications, that is not a reason to give a B grade. I asked a lot of questions and you did not even bother to reply to them. It is your fault that you did not get a good enough answer, not mine.

Hence, you are the 7th person to make it on my blacklist. Which basically means that from now on and forever I will ignore your every question.
If you treat other experts like this, that follow a similar policy as myself, you will soon find yourself with little or no experts to answer your questions.

This is just a notice. No need to reply as I unsubscribed from this question.

Enjoy.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question