Posts

Showing posts from February, 2012

MSSQL - Alter Column Data Type

In normally in SQL, syntax for alter table is ALTER TABLE table_name MODIFY column_name data_type Example. ALTER TABLE products MODIFY product_name VARCHAR2(50) But if in MSSQL, you have to use "ALTER COLUMN" instead. ALTER TABLE table_name ALTER COLUMN column_name data_type Example. ALTER TABLE products ALTER COLUMN product_name varchar(50)

C# - AES Encrypt

input: string message, string keycode output: string BASE64String using System.Security.Cryptography; RijndaelManaged aesCipher = new RijndaelManaged(); ASCIIEncoding textConverter = new ASCIIEncoding(); Byte[] iv; aesCipher.KeySize = 128; aesCipher.BlockSize = 128; aesCipher.Mode = CipherMode.ECB; aesCipher.Padding = PaddingMode.Zeros; aesCipher.Key = textConverter.GetBytes(keycode); ICryptoTransform crypto = aesCipher.CreateEncryptor(); Byte[] toEncrypt = textConverter.GetBytes(messg); Byte[] cipherText = crypto.TransformFinalBlock(toEncrypt, 0, toEncrypt.Length); String base64Str = ""; base64Str = Convert.ToBase64String(cipherText);