Data encryption with C # (2) - hash algorithm

zhaozj2021-02-16  53

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 /// public class hashcryptoservice; /// /// has a constructor of the Hash plus secret function //// public hashmethod () {hashcryptoservice = new sha1managed ();} /// /// encryption method //// / summary> /// String to be encrypted /// Encrypted string public string encrypto (string source) {byte [] bytin = utf8encoding.utf8.getbytes; byte [] Bytout = Hashcryptoservice.computehash (Bytin) Return Convert.TOBASE64String (Bytout);}}}

转载请注明原文地址:https://www.9cbs.com/read-24826.html

New Post(0)