public static byte[] csHashBytes(string Message) { byte[] MessageBytes = TCipher.RegularStringToBytes(Message); SHA1 sha = new SHA1CryptoServiceProvider(); return(sha.ComputeHash(MessageBytes)); }
public static int csHashint32(this string MessageString) // Secure hash { if (MessageString == null) { return(0); } //convert the string into an array of Unicode bytes. byte[] MessageBytes = TCipher.RegularStringToBytes(MessageString); //Create a new instance of the SHA1Managed class to create //the hash value. SHA1Managed SHhash = new SHA1Managed(); //Create the hash value from the array of bytes. byte[] HashValue = SHhash.ComputeHash(MessageBytes); int v = 0; for (int i = 6; i < 10; i++) { byte b = HashValue[i]; v = (v << 8) + HashValue[i]; } return(v); }
//public static string RSAEncrypt(string PlainText, string Key) //{ // byte[] plainBytes = TCipher.RegularStringToBytes(PlainText); // return TCipher.BytesToRegularString(RSAEncrypt(plainBytes, Key)); //} public static string RSAEncryptToBase64(string PlainText, string Key) { byte[] plainBytes = TCipher.RegularStringToBytes(PlainText); return(TCipher.BytesToBase64String(RSAEncrypt(plainBytes, Key))); }