C # in a string encryption

xiaoxiao2021-03-06  111

You can use DSA and RSA, such as: use system.sem.text; using system.security.cryptography;

Class DSacrypto_SIGNDATA {public static void main (String [] args) {// First convert a string into a byte array, which is related to coding. String str = "this is a test."; Byte [] bytes = encoding.ascii.getbytes (STR); // Select the signature method, RSA and DSA DSACryptoserviceProvider DSAC = New dsacryptoserviceProvider (); byte [] Sign = DSAC. SIGNDATA (BYTES); // Sign is the signature result.

// The following is authenticated DSACryptoServiceProvider dsac2 = new DSACryptoServiceProvider (); dsac2.FromXmlString (dsac.ToXmlString (false)); bool ver = dsac2.VerifyData (bytes, sign); if (ver) {Console.WriteLine ( "through" } Else {console.writeline ("cannot pass");}}}

RSA is similar, but RSA is much slower than DSA, but is safe than DSA. RSA can select the size of the keyword, the larger the security

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

New Post(0)