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); } }
internal static BigInteger CalculateDHSharedKey(string PublicKey) { try { byte[] CBytes = Converter.HexStringToBytes(PublicKey); byte[] KeyBytes = Rsa.Verify(CBytes); string KeyString = Encoding.Default.GetString(KeyBytes); return(DiffieHellman.CalculateSharedKey(new BigInteger(KeyString, 10))); } catch { return(0); } }