Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
Learn How to Create Your Own Programming Language
createyourproglang.com
Recent
FILE HOSTS PREMIUM ACCOUNT
ALL FILE HOST PREMIUM ACCOUNTS
Zynga Slingo Trainer v5.12
iTunes Gift Card Generator V3.1 2012
Diablo 3 GOLD Coins FREE
Working PS3 Jailbreak 3.65 And 3.66
ExtaBit Premium Accounts and Cookies
Steam Wallet Hack - Money Adder & Hack v3
Empires & Allies Hack Cheat Trainer v5.4.1
Eve Onnline 60 Days Time Card Generator v2
Popular
XBOX POINTS GENERATOR - MICROSOFT POINTS GENERATOR v1.2012
11 may 2012 premium uploading accounts 100% working
Free Microsoft Points
Free Microsoft Points - Microsoft Points Generator - Xbox Live Codes 2012
Car Town Free Blue Points Hack
Free CarTown Blue Points Generator and CarTown Templates
Better way to get content via jQuery $.get()
Free Microsoft Points
Simple Days Purger
Sharecash Downloader Bypass Surveys New 05/2012
Pastable version of
Encryption and Decryption
<pre class='prettyprint' language='cs'>// ***** Encryption and Decryption ***** // byte[] Key(string sText) { if (Encoding.Default.GetBytes(sText).Length > 32) { throw new ArgumentException("Key must be less than 32 bytes long."); } if (Encoding.Default.GetBytes(sText).Length < 1) { throw new ArgumentException("Key must be more than 0 bytes long."); } while (Encoding.Default.GetBytes(sText).Length < 32) { sText = sText + " "; } return Encoding.Default.GetBytes(sText); } string Encrypt(string sText) { // Convert Input Text into Bytes Array byte[] bText = Encoding.Default.GetBytes(sText.Trim()); // For storing encrypted bytes MemoryStream mStream = new MemoryStream(); // get the algorithm to use SymmetricAlgorithm alg = SymmetricAlgorithm.Create("Rijndael"); // Specify Block and Key Size alg.BlockSize = 256; alg.KeySize = 256; // Create our own Key and IV byte[] key = Key("34553513543651433545343545789341"); byte[] iv = {1,5,6,7,8,1,3,4,5,7,8,9,2,4,5,6,4,5,6,2,4,5,6,4,6,4,2,3,4,8,6,2}; ICryptoTransform encryptor = alg.CreateEncryptor(key, iv); //CreateEncryptor(Byte[] rgbKey, Byte[] rgbIV) // Tell the crypto stream where and how to encrypt CryptoStream crypto = new CryptoStream(mStream, encryptor, CryptoStreamMode.Write); // Do the actually encryption crypto.Write(bText, 0, bText.Length); crypto.Close(); // Byte array with encrypted data byte[] cipher = mStream.ToArray(); // Return Encrypted Text return Convert.ToBase64String(cipher); } string Decrypt(string sText) { // Convert Input Text into Bytes Array byte[] bText = Convert.FromBase64String(sText); // For storing encrypted bytes MemoryStream mStream = new MemoryStream(bText); // get the algorithm to use SymmetricAlgorithm alg = SymmetricAlgorithm.Create("Rijndael"); // Specify Block and Key Size alg.BlockSize = 256; alg.KeySize = 256; // Create our own Key and IV byte[] key = Key("34953913543651433549343595789391"); byte[] iv = {1,5,6,7,9,1,3,4,5,7,8,9,2,4,9,6,4,5,6,2,4,5,6,4,6,4,2,9,4,8,6,2}; ICryptoTransform decryptor = alg.CreateDecryptor(key, iv); //CreateDecryptor(Byte[] rgbKey, Byte[] rgbIV) // Tell the crypto stream where and how to decrypt CryptoStream crypto = new CryptoStream(mStream, decryptor, CryptoStreamMode.Read); // Do the actually decryption byte[] bOutput = new byte[bText.Length - 1 + 1]; crypto.Read(bOutput, 0, bText.Length); crypto.Close(); // Return Decrypted Text return Encoding.Default.GetString(bOutput).Replace("\x000", String.Empty); }</pre> <a href="http://www.refactormycode.com/codes/334-encryption-and-decryption" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://www.refactormycode.com/images/small_logo.gif" style="border:0" /></a>