Discuss the encryption of strings in C # (Save)

xiaoxiao2021-03-06  36

The encryption of the string in the C # can be converted to the byte array with DSA and RSA, which is related to the coding. Select the signature method, there are RSA and DSA, Sign is the signature result.

You can use DSA and RSA, such as:

Using system;

Using system.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-58450.html

New Post(0)