Implementation method for encrypted and decryption in .NET 3

xiaoxiao2021-03-06  16

//

Encrypt the symmetric key and send it to the guest using the client's public key.

EncryptandSymmetricKey (Client, RSA, SYMM); //

Use symmetric key encryption information and send

EncryptandsendSecretMessage (Client, SYMM, MSG);} catch (exception e) {console.writeline (E.MESSAGE); Console.Writeline (E.STACKTRACE);} finally {try {client.close (); listener.stop () } catCH {////

error

} Console.writeline ("Server EXITING ...");}}} private static rsaparameters getClientPublicKey (TCPCLIENT Client) {//

Get a serialized public key from the byte stream, by string and convert the write class

byte [] buffer = new byte [RSA_KEY_SIZE_BYTES]; NetworkStream ns = client.GetStream (); MemoryStream ms = new MemoryStream (); BinaryFormatter bf = new BinaryFormatter (); RSAParameters result; int len ​​= 0; int totalLen = 0;

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

New Post(0)