Re: TripleDES output size
- From: "Joe Kaplan" <joseph.e.kaplan@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 9 Oct 2006 12:15:07 -0500
It depends on how you are converting your string data to binary (what
encoding) and how you are converting your binary cipher data back to a
string.
If you are using UTF-8 for converting string to binary (generally a good
idea), then the downside there is that the binary data can be variable
length, depending on the characters in the string. If you use Unicode
encoding, then you should always get two bytes per character.
Then, you can figure out how many bytes of cipher data you'll get by
rounding up to the block size.
If you convert from your binary data to string with Base64 (which is
probably the best way to go, as it is smaller than hex string and won't
result in lossy conversion), then the base64 string will be 4/3 the size of
the binary data.
Make sense?
Are you just trying to decide how big to make your columns in SQL given
input strings of a certain length?
Joe K.
--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
"Arturo Buonanni" <leave_this_out_deer.chief.this.also@xxxxxxxxx> wrote in
message news:3ivki25mnjtgc3vkhigjl8icetgcd2krtu@xxxxxxxxxx
On 5 Oct 2006 23:28:53 -0700, "Valery Pryamikov" <valery@xxxxxxxxx>
wrote:
Thanks for your reply but it doesn't help me.
I mean. Let's say I've a 5 chars string I want to encrypt.
Encrypting it using .NET framewirk TripleDESCryptoServiceProvider
gives me a string of 24 chars lenght.
Now how can I calculate the length of the crypted string based on the
size of the plain one?
Thanks.
HI,
3DES has 8 bytes (64 bits) block size.
if you use it with default CBC mode of encryption, the last block is
always padded to make it a full block. In case if plain text size is
exact multiple of 8 bytes, then the whole block of padding is added.
-Valery.
http://www.harper.no/valery
Arturo Buonanni wrote:
Hello to all,
I'm new to cryptography and I've to implement encryption of data into
a database.
I'm using .NET framework TripleDESCryptoServiceProvider to crypt and
decrypt strings.
Anyway I can not find any reference on how to calculate the length of
the encrypted string based on the length of the plain string.
As I've to store the encrypted data into table fields, I've to be sure
it fits into the field size.
Does anybody knows how to do this?
Thanks.
(I'm posting this also to microsoft.public.security.crypto)
.
- Follow-Ups:
- Re: TripleDES output size
- From: Arturo Buonanni
- Re: TripleDES output size
- References:
- TripleDES output size
- From: Arturo Buonanni
- Re: TripleDES output size
- From: Valery Pryamikov
- Re: TripleDES output size
- From: Arturo Buonanni
- TripleDES output size
- Prev by Date: Re: TripleDES output size
- Next by Date: Help me to understand Code Access Security. I don't get it.
- Previous by thread: Re: TripleDES output size
- Next by thread: Re: TripleDES output size
- Index(es):
Relevant Pages
|