Page 1 of 1

Max length of encrypted encoded string

Posted: Tue Jul 04, 2006 6:30 am
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

Posted: Tue Jul 04, 2006 7:33 am
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?

Posted: Tue Jul 04, 2006 8:14 am
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

Posted: Tue Jul 04, 2006 8:19 am
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.

Posted: Tue Jul 04, 2006 11:39 am
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

Posted: Tue Jul 04, 2006 12:05 pm
by madshi
Encrypt adds 1-7 bytes. Encode does this to the size:

"SetLength(result, ((len + 2) div 3) * 4)"

Posted: Tue Jul 04, 2006 4:36 pm
by Jacobh
Thanks for your help!