The secret process in RSA is mainly for DES symmetric encryption key
Generally, user a encrypts the key with the public key of user B, and user B decrypts the key with the private key after receiving the information.
Public String rsaencode (string originstring)
{
Rsaparameters prvkeyinfo = rsaparamparser. parsersaparam (publicfile); // publicfile address
Rsacryptoserviceprovider RSA = new rsacryptoserviceprovider ();
RSA. importparameters (pubkeyinfo );
Byte [] DATA = system. Text. encoding. Default. getbytes (originstring );
Return System. Convert. tobase64string (RSA. Encrypt (data, false ));
}
Public String rsadecode (byte [] encrypteddata)
{
Rsaparameters prvkeyinfo = rsaparamparser. parsersaparam (privatefile); // privatefile address
Rsacryptoserviceprovider RSA = new rsacryptoserviceprovider ();
RSA. importparameters (prvkeyinfo );
Return System. Convert. tobase64string (RSA. decrypt (encrypteddata, false ));
}
If pubkey is in string format
Byte [] keydata = system. Convert. frombase64string (pubkey );
Rsaparameters Param = rsaparamparser. parsersaparam (keydata );