Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

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);
	}

Aes.txt

  • Administrators
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...