public static BigInteger CalculateDiffieHellmanSharedKey(string publicKey) { try { byte[] cbytes = Converter.HexStringToBytes(publicKey); byte[] publicKeyBytes = Rsa.Decrypt(cbytes); string publicKeyString = Encoding.Default.GetString(publicKeyBytes); return(DiffieHellman.CalculateSharedKey(new BigInteger(publicKeyString, 10))); } catch { return(0); } }