Max length of encrypted encoded string

delphi package - madRes, madTools, madStrings, ...
Post Reply
Jacobh
Posts: 30
Joined: Tue Aug 30, 2005 9:01 am

Max length of encrypted encoded string

Post by Jacobh »

Hi there.

I bit of information I couldn't find in the help file:

If I've got a string of max 20 chars, whats the upper limit on the length of the string, after it has been ecrypted and encoded?

Thanks
Jacob Havkrog
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

I'm not sure what you mean. Are you asking whether there's a limit about how long a string may be that you give into the encryption/encoding routines? Or are you asking how long the resulting string will be? Or something else?
Jacobh
Posts: 30
Joined: Tue Aug 30, 2005 9:01 am

Post by Jacobh »

Hi.

Sorry for being unclear.

Simply, I want to encrypt and encode a password string in order to save it to my database.

I just need to know the necessary size of the database field. Is a field length of 50 chars enough?

In clear text, my password is of max 20 chars.

pw := '12345678901234567890';

Encrypt(pw, '8nwe3r7');
x := Encode(s);

Whats the max length of x that I need to worry about? Does it depend on the encryption key?

Thanks
Jacob
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

It does not depend on the encryption key nor on the content of the original data. The length of the resulting string only depends on the length of the original to-be-encrypted data.
Jacobh
Posts: 30
Joined: Tue Aug 30, 2005 9:01 am

Post by Jacobh »

Hi again. I'll try to ask a more specific question.

Does the Encrypt(x, y) procedure preserve the length of the var parameter x?

Or is safe to say, that the lenght of x is no longer than doubled?

In other words:

For all strings x of length <= a:

Execute procedure call Encrypt(x, y)

Is it subsequentially true, that Length(x) <= 2*a ?

Or, can you give another constant instead of "2"?

Thanks
Jacob
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Encrypt adds 1-7 bytes. Encode does this to the size:

"SetLength(result, ((len + 2) div 3) * 4)"
Jacobh
Posts: 30
Joined: Tue Aug 30, 2005 9:01 am

Post by Jacobh »

Thanks for your help!
Post Reply