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

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

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

    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. Guest

  2. Similar Questions and Discussions

    1. #26280 [Bgs]: update query cut off with ascii char > 128
      ID: 26280 User updated by: jochen dot daum at cabletalk dot co dot nz Reported By: jochen dot daum at cabletalk dot co dot nz...
    2. #26280 [Opn->Bgs]: update query cut off with ascii char > 128
      ID: 26280 Updated by: fmk@php.net Reported By: jochen dot daum at cabletalk dot co dot nz -Status: Open...
    3. #26280 [Fbk->Opn]: update query cut off with ascii char > 128
      ID: 26280 User updated by: jochen dot daum at cabletalk dot co dot nz Reported By: jochen dot daum at cabletalk dot co dot nz...
    4. #26280 [Opn->Fbk]: update query cut off with ascii char > 128
      ID: 26280 Updated by: moriyoshi@php.net Reported By: jochen dot daum at cabletalk dot co dot nz -Status: Open...
    5. #26280 [NEW]: update query cut off with ascii char > 128
      From: jochen dot daum at cabletalk dot co dot nz Operating system: Linux Debian woody PHP version: 4CVS-2003-11-16 (stable) PHP...
  3. #2

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

    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." <charlestek@rcn.com> wrote in message
    news:OHdnoOsGFHA.3916@TK2MSFTNGP12.phx.gbl...
    > 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\) Guest

  4. #3

    Default 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)" <joseph.e.kaplan@removethis.accenture.com> wrote
    in message news:uElSEj0GFHA.1172@TK2MSFTNGP12.phx.gbl...
    > 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." <charlestek@rcn.com> wrote in message
    > news:OHdnoOsGFHA.3916@TK2MSFTNGP12.phx.gbl...
    >> 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. Guest

  5. #4

    Default 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." <charlestek@rcn.com> wrote in message
    news:ufEZxw0GFHA.2744@tk2msftngp13.phx.gbl...
    > 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)" <joseph.e.kaplan@removethis.accenture.com> wrote
    > in message news:uElSEj0GFHA.1172@TK2MSFTNGP12.phx.gbl...
    >> 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." <charlestek@rcn.com> wrote in message
    >> news:OHdnoOsGFHA.3916@TK2MSFTNGP12.phx.gbl...
    >>> 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\) Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139