Database field type for AES Encryption in hex or base64

What field type should I choose when encrypting data using AES?  I plan to use either hex or base64 encoding, and the data being encrypted is anywhere from 9 - 16 digits in length.
queetAsked:
Who is Participating?
 
K VConnect With a Mentor Database ConsultantCommented:
If ur sure about lenght u can go for varchar(maxlenght)
otherwise better to go for TINYBLOB
0
 
UmeshConnect With a Mentor MySQL Principle Technical Support EngineerCommented:
Because AES is a block-level algorithm, padding is used to encode uneven length strings and so the result string length may be calculated using this formula:

16 × (truncate(string_length / 16) + 1)

In your case string_length  is anywhere from 9 - 16 digits in length.

select 16*(TRUNCATE(16/16,0)+1) from dual => 32

I suggest you to use eather varchar(32).. or varbinary..

http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html
0
 
UmeshMySQL Principle Technical Support EngineerCommented:
0
 
queetAuthor Commented:
Thanks!
0
All Courses

From novice to tech pro — start learning today.