Max length of encrypted encoded string

delphi package - madRes, madTools, madStrings, ...

Max length of encrypted encoded string

Postby Jacobh » Tue Jul 04, 2006 6:30 am

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
Jacobh
 
Posts: 30
Joined: Tue Aug 30, 2005 9:01 am

Postby madshi » Tue Jul 04, 2006 7:33 am

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?
madshi
Site Admin
 
Posts: 9338
Joined: Sun Mar 21, 2004 5:25 pm

Postby Jacobh » Tue Jul 04, 2006 8:14 am

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
Jacobh
 
Posts: 30
Joined: Tue Aug 30, 2005 9:01 am

Postby madshi » Tue Jul 04, 2006 8:19 am

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.
madshi
Site Admin
 
Posts: 9338
Joined: Sun Mar 21, 2004 5:25 pm

Postby Jacobh » Tue Jul 04, 2006 11:39 am

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
Jacobh
 
Posts: 30
Joined: Tue Aug 30, 2005 9:01 am

Postby madshi » Tue Jul 04, 2006 12:05 pm

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

"SetLength(result, ((len + 2) div 3) * 4)"
madshi
Site Admin
 
Posts: 9338
Joined: Sun Mar 21, 2004 5:25 pm

Postby Jacobh » Tue Jul 04, 2006 4:36 pm

Thanks for your help!
Jacobh
 
Posts: 30
Joined: Tue Aug 30, 2005 9:01 am


Return to madBasic

Who is online

Users browsing this forum: No registered users and 1 guest