Data encryption with C # (2) - hash algorithm
The following is a hash encryption with C #, everyone can change the desired algorithm according to their needs, and SHA1 as an example:
Using system; using system.seircurity.cryptography; using system.text;
Namespace Datacrypto {/// /// hash plus secret class /// summary> public class hashcryptoservice; /// /// has a constructor of the Hash plus secret function //// summary> public hashmethod () {hashcryptoservice = new sha1managed ();} /// /// encryption method //// / summary> /// String to be encrypted param> /// Encrypted string returns> public string encrypto (string source) {byte [] bytin = utf8encoding.utf8.getbytes; byte [] Bytout = Hashcryptoservice.computehash (Bytin) Return Convert.TOBASE64String (Bytout);}}}