Storing 3DES Encrypted string in an MSSQL Database column

S

Sam Evans

All,

I am using System.Security.Cryptography to create a 3DES encrypted
string which I need to store in row in a MSSQL database. I was
wondering which datatype would be an appropriate match? I am guessing a
BLOB would work but want to make sure before harassing the DBA's.

Thanks!
 
G

Guest

Hi Sam,
I have just done the same thing. I left the PAN in the datadase as an
nvarchar and simply used the following to produce the right string :

byte[] cipherText = Enc.Encrypt(pan, key);// this gives a byte encrypted pan
panstring = Convert.ToBase64String(cipherText);//this converts the byte
format to a varchar string for the dbase

Obviously you have your own version of the Enc.Encrypt() function!
 
S

Sam Evans

This is perfect, thank you very much!

White said:
Hi Sam,
I have just done the same thing. I left the PAN in the datadase as an
nvarchar and simply used the following to produce the right string :

byte[] cipherText = Enc.Encrypt(pan, key);// this gives a byte encrypted pan
panstring = Convert.ToBase64String(cipherText);//this converts the byte
format to a varchar string for the dbase

Obviously you have your own version of the Enc.Encrypt() function!



:

All,

I am using System.Security.Cryptography to create a 3DES encrypted
string which I need to store in row in a MSSQL database. I was
wondering which datatype would be an appropriate match? I am guessing a
BLOB would work but want to make sure before harassing the DBA's.

Thanks!
 
S

Sam Evans

Well, I thought I had this down but it is proving more of a challenge
than I had thought. I'm using the basic 3DES encryptor but am running
into problems decrypting the data from Base64.

I understand that I have to convert it back *from* Base64, but for
whatever reason, it's giving me an invalid data type. I will keep
playing with it, but if you can give me any pointers, I would be truly
grateful.

Thanks,
Sam


White said:
Hi Sam,
I have just done the same thing. I left the PAN in the datadase as an
nvarchar and simply used the following to produce the right string :

byte[] cipherText = Enc.Encrypt(pan, key);// this gives a byte encrypted pan
panstring = Convert.ToBase64String(cipherText);//this converts the byte
format to a varchar string for the dbase

Obviously you have your own version of the Enc.Encrypt() function!



Sam Evans said:
All,

I am using System.Security.Cryptography to create a 3DES encrypted
string which I need to store in row in a MSSQL database. I was
wondering which datatype would be an appropriate match? I am guessing a
BLOB would work but want to make sure before harassing the DBA's.

Thanks!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top