Re: TripleDES output size



On Mon, 9 Oct 2006 12:15:07 -0500, "Joe Kaplan"
<joseph.e.kaplan@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:

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?

It makes perfect sense. Thanks.
I indeed use unicode encoding to feed the encryption provider and then
convert the binary data to string with Base64. It turns out to be:

CipherTextLength = _
((((Trunc((PlainTextLength * 2) \ 8) + 1) * 8) \ 3) + 1) * 4

The problem is that only now I realize I'm making my strings quite
big...:-(
Anyway, as I need to use Italian character set, I think I'm forced to
use at least UTF-8. In that case I should howerver consider the worst
case in wich every character of my string is a 2 byte code so I end up
having field the same size as using Unicode. :-(

Are you just trying to decide how big to make your columns in SQL given
input strings of a certain length?

That's exactly what I'm trying to do.
Thanks for your help.

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
.



Relevant Pages

  • Re: Pre-information on Unicode in Delphi 2008
    ... Well IMO this is one case where Delphi isn't doing strong typing, there should be a warning there and a requirement for an explicit cast. ... Converting from Ansi to Wide while assuming the Ansi is using the system_locale is just an assumption, and in the Delphi IDE itself, that can results in string corruption when editing DFMs, and before you ask, yes there are QCs on the subject:) ... AnsiString have no particular encoding at all, assuming *any* encoding for automagic conversion is going to result in hard-to-track cases of data ...
    (borland.public.delphi.non-technical)
  • Re: Why asci-only symbols?
    ... >> Perhaps string equivalence in keys will be treated like numeric equivalence? ... I know typewill be and in itself contain no encoding information now, ... >and a Unicode string, the system default encoding ...
    (comp.lang.python)
  • Re: Byte Array to String
    ... retrieved text will mismatch the original characters. ... encoding the characters. ... Dim strFileData as String ...
    (microsoft.public.dotnet.framework.aspnet)
  • F is evil (was: XML::LibXML UTF-8 toString() -vs- nodeValue())
    ... And with C<use encoding 'utf8';> you'll get the same character string, ... A script is the complete program text, ...
    (comp.lang.perl.misc)
  • Re: eval and unicode
    ... encoding your terminal/file/whatnot is written in. ... you have a byte string that starts with u, then ", then something ... The first item in the sequence is \u5fb9 -- a unicode code point. ...
    (comp.lang.python)