Datatype for Encryption AES 256 BIT

daniel2milan

Newcomer
Joined
Sep 3, 2005
Messages
7
guys i have problem to store result of encryption AES 256 BIT or 128 BIT on SQL server 2000...

can you suggest what datatype i should use for this?

herewith i attach the class... please simple change the extention into .cs

i use .net 2003 and C#

and i use this function to get the encrypted data
Code:
public string AES_encrypt(string plaintext)
		{
			keysize = Aes.KeySize.Bits128;
			byte[] plainText = new byte[16];
			byte[] cipherText = new byte[16];  
      
			plainText = Encoding.Unicode.GetBytes(plaintext.PadRight(8,' '));
			AesLib.Aes a = new Aes(keysize, new byte[16]);
			a.Cipher(plainText, cipherText);
			//label2.Text = Encoding.Unicode.GetString(cipherText);
			return  Encoding.Unicode.GetString(cipherText);
		}

		
		public string AES_decrypt(string chipertext)
		{
			//decoding
			keysize = Aes.KeySize.Bits128;
			byte[] cipherText = new byte[16];
			byte[] decipheredText = new byte[16];

			cipherText = Encoding.Unicode.GetBytes(chipertext);
			AesLib.Aes a = new Aes(keysize, new byte[16]);
			a.InvCipher(cipherText, decipheredText);
			//textBox3.Text = Encoding.Unicode.GetString(decipheredText);;
			return Encoding.Unicode.GetString(decipheredText);
		}
 

Attachments

As both the functions return / accept string based data then depending on the size likely to be returned either a varchar or text data type might be the best.

Although as you are using unicode strings nvarchar or ntext is probably more suitable.
 
Back
Top