How Many VarBinary for each Ascii Char Aes Encrypted KeySize=256,BlockSize=256

Discussion in 'ASP .Net Security' started by Phil C., Feb 24, 2005.

  1. Phil C.

    Phil C. Guest

    Hi. I'm wanting to encrypt customer name, address, etc. information using
    Aes with a KeySize of 256 and a BlockSize of 256. Either for each ascii
    character or say for a maximum length 50 characters for a field, how many
    bytes will this generate and how do I translate
    this into the number of VarBinary ???items that I allocate in my Sql Server
    2000 table??

    Phil
    Boston, MA
     
    Phil C., Feb 24, 2005
    #1
    1. Advertising

  2. I'd suggest the best thing to do would be to try it out and see. AES uses
    padding backed on the block size, so you should get consistent sizes back.
    Assuming you are using UTF8 encoding to convert your plain text to a byte
    array for encryption, you could potentially get variable sizes of input
    data, but if all of the characters you are encoding are ASCII, then that
    should be consistent as well.

    You might also consider converting your encrypted data to Base64 to store in
    the db. That might be easier to deal with than storing as raw binary. It
    will be 4/3 the size of the original byte array, but then you can just use
    varchar.

    Joe K.

    "Phil C." <> wrote in message
    news:...
    > Hi. I'm wanting to encrypt customer name, address, etc. information using
    > Aes with a KeySize of 256 and a BlockSize of 256. Either for each ascii
    > character or say for a maximum length 50 characters for a field, how many
    > bytes will this generate and how do I translate
    > this into the number of VarBinary ???items that I allocate in my Sql
    > Server 2000 table??
    >
    > Phil
    > Boston, MA
    >
     
    Joe Kaplan \(MVP - ADSI\), Feb 25, 2005
    #2
    1. Advertising

  3. Phil C.

    Phil C. Guest

    Thank You; How Many VarBinary for each Ascii Char Aes Encrypted KeySize=256,BlockSize=256

    Joe,

    Thanks again for the detailed advice.
    VarBinary seems also somewhat nebulous to me, as the definition I get from
    Robert Viera's
    Sql Server 2000 Programming Book says:
    "Size in Bytes: 'Varies' ", "Variable length binary data with a maximum
    length of
    8,000 bytes."

    So lets say I use UTF8, for 50 ascii characters I would expect 50 bytes, and
    from the above VarBinary
    definition, this implies that I could get away with the database column as
    VarBinary 1 ???

    Phil


    "Joe Kaplan (MVP - ADSI)" <> wrote
    in message news:...
    > I'd suggest the best thing to do would be to try it out and see. AES uses
    > padding backed on the block size, so you should get consistent sizes back.
    > Assuming you are using UTF8 encoding to convert your plain text to a byte
    > array for encryption, you could potentially get variable sizes of input
    > data, but if all of the characters you are encoding are ASCII, then that
    > should be consistent as well.
    >
    > You might also consider converting your encrypted data to Base64 to store
    > in the db. That might be easier to deal with than storing as raw binary.
    > It will be 4/3 the size of the original byte array, but then you can just
    > use varchar.
    >
    > Joe K.
    >
    > "Phil C." <> wrote in message
    > news:...
    >> Hi. I'm wanting to encrypt customer name, address, etc. information
    >> using Aes with a KeySize of 256 and a BlockSize of 256. Either for each
    >> ascii character or say for a maximum length 50 characters for a field,
    >> how many bytes will this generate and how do I translate
    >> this into the number of VarBinary ???items that I allocate in my Sql
    >> Server 2000 table??
    >>
    >> Phil
    >> Boston, MA
    >>

    >
    >
     
    Phil C., Feb 25, 2005
    #3
  4. Re: Thank You; How Many VarBinary for each Ascii Char Aes Encrypted KeySize=256,BlockSize=256

    SQL is definitely not my thing and I've never used a varbinary column.

    With AES, if you input 50 bytes, you should get an even multiple of 256 bits
    (32 bytes) back, so I'd expect it will take 64 bytes to store 50 plain input
    bytes. UTF8 should produce 50 bytes for 50 ASCII characters.

    I still like the idea of using varchar and coverting your encrypted output
    to base64. Then you store in SQL as a simple string. Seems easier to deal
    with to me.

    Joe K.

    "Phil C." <> wrote in message
    news:...
    > Joe,
    >
    > Thanks again for the detailed advice.
    > VarBinary seems also somewhat nebulous to me, as the definition I get from
    > Robert Viera's
    > Sql Server 2000 Programming Book says:
    > "Size in Bytes: 'Varies' ", "Variable length binary data with a maximum
    > length of
    > 8,000 bytes."
    >
    > So lets say I use UTF8, for 50 ascii characters I would expect 50 bytes,
    > and from the above VarBinary
    > definition, this implies that I could get away with the database column as
    > VarBinary 1 ???
    >
    > Phil
    >
    >
    > "Joe Kaplan (MVP - ADSI)" <> wrote
    > in message news:...
    >> I'd suggest the best thing to do would be to try it out and see. AES
    >> uses padding backed on the block size, so you should get consistent sizes
    >> back. Assuming you are using UTF8 encoding to convert your plain text to
    >> a byte array for encryption, you could potentially get variable sizes of
    >> input data, but if all of the characters you are encoding are ASCII, then
    >> that should be consistent as well.
    >>
    >> You might also consider converting your encrypted data to Base64 to store
    >> in the db. That might be easier to deal with than storing as raw binary.
    >> It will be 4/3 the size of the original byte array, but then you can just
    >> use varchar.
    >>
    >> Joe K.
    >>
    >> "Phil C." <> wrote in message
    >> news:...
    >>> Hi. I'm wanting to encrypt customer name, address, etc. information
    >>> using Aes with a KeySize of 256 and a BlockSize of 256. Either for each
    >>> ascii character or say for a maximum length 50 characters for a field,
    >>> how many bytes will this generate and how do I translate
    >>> this into the number of VarBinary ???items that I allocate in my Sql
    >>> Server 2000 table??
    >>>
    >>> Phil
    >>> Boston, MA
    >>>

    >>
    >>

    >
    >
     
    Joe Kaplan \(MVP - ADSI\), Feb 25, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. M-One
    Replies:
    43
    Views:
    1,554
    Mark McIntyre
    Jul 16, 2003
  2. Ning

    pycrypto 3DES keysize

    Ning, Dec 13, 2006, in forum: Python
    Replies:
    2
    Views:
    453
  3. Phil C.

    DpAPI Encrypted Aes Key Problems

    Phil C., Mar 5, 2005, in forum: ASP .Net Security
    Replies:
    0
    Views:
    348
    Phil C.
    Mar 5, 2005
  4. Phil C.
    Replies:
    0
    Views:
    258
    Phil C.
    Apr 27, 2006
  5. Nate Wiger

    New AES gem available -- fast-aes

    Nate Wiger, Jan 20, 2010, in forum: Ruby
    Replies:
    3
    Views:
    229
    Pål Bergström
    Jul 1, 2010
Loading...

Share This Page