?
Solved

Database field type for AES Encryption in hex or base64

Posted on 2008-11-02
4
Medium Priority
?
711 Views
Last Modified: 2012-05-05
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
Comment
Question by:queet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 21

Accepted Solution

by:
K V earned 1000 total points
ID: 22865021
If ur sure about lenght u can go for varchar(maxlenght)
otherwise better to go for TINYBLOB
0
 
LVL 26

Assisted Solution

by:Umesh
Umesh earned 1000 total points
ID: 22865085
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
 
LVL 26

Expert Comment

by:Umesh
ID: 22867267
0
 

Author Closing Comment

by:queet
ID: 31512602
Thanks!
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ransomware is a growing menace to anyone using a computer or mobile device. Here are answers to some common questions about this vicious new form of malware.
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question