public static byte[] EnCrypt(string sClearText) { CryptoStat ct = new CryptoStat(); ct.Initialize("tobeornot", "tobealive", 128); Byte[] inBytes = new Byte[sClearText.Length]; for (int i = 0; i < sClearText.Length; ++i) { inBytes[i] = (byte)sClearText[i]; } Byte[] encrypted = ct.GetEncryptedBytes(inBytes); StringBuilder sbencrypted = new StringBuilder(); for (int i = 0; i < encrypted.Length; ++i) { sbencrypted.Append(encrypted[i]); if (i < (encrypted.Length - 1)) { sbencrypted.Append(";"); } } return(encrypted); }
public static string DeCrypt(byte[] encrypted) { CryptoStat ct = new CryptoStat(); ct.Initialize("tobeornot", "tobealive", 128); Byte[] deCrypted = ct.DecryptBytes(encrypted, encrypted.Length); StringBuilder sb = new StringBuilder(); for (int i = 0; i < deCrypted.Length; ++i) { sb.Append((char)deCrypted[i]); } return sb.ToString(); }
public static string DeCrypt(byte[] encrypted) { CryptoStat ct = new CryptoStat(); ct.Initialize("tobeornot", "tobealive", 128); Byte[] deCrypted = ct.DecryptBytes(encrypted, encrypted.Length); StringBuilder sb = new StringBuilder(); for (int i = 0; i < deCrypted.Length; ++i) { sb.Append((char)deCrypted[i]); } return(sb.ToString()); }
public static byte[] EnCrypt(string sClearText) { CryptoStat ct = new CryptoStat(); ct.Initialize("tobeornot", "tobealive", 128); Byte[] inBytes = new Byte[sClearText.Length]; for (int i = 0; i < sClearText.Length; ++i) { inBytes[i] = (byte)sClearText[i]; } Byte[] encrypted = ct.GetEncryptedBytes(inBytes); StringBuilder sbencrypted = new StringBuilder(); for (int i = 0; i < encrypted.Length; ++i) { sbencrypted.Append(encrypted[i]); if (i < (encrypted.Length - 1)) sbencrypted.Append(";"); } return encrypted; }