Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 715
  • Last Modified:

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.
0
queet
Asked:
queet
  • 2
2 Solutions
 
K VDatabase ConsultantCommented:
If ur sure about lenght u can go for varchar(maxlenght)
otherwise better to go for TINYBLOB
0
 
UmeshCommented:
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
 
UmeshCommented:
0
 
queetAuthor Commented:
Thanks!
0

Featured Post

2017 Webroot Threat Report

MSPs: Get the facts you need to protect your clients.
The 2017 Webroot Threat Report provides a uniquely insightful global view into the analysis and discoveries made by the Webroot® Threat Intelligence Platform to provide insights on key trends and risks as seen by our users.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now