Sha256: 97d534917dd5414662aebdf17f8594e6e049780b327f7162bfb3b25df811a87d

Contents?: true

Size: 554 Bytes

Versions: 396

Compression:

Stored size: 554 Bytes

Contents

using System;
using System.Numerics;

public static class DiffieHellman
{
    private static readonly Random Random = new Random();

    public static BigInteger PrivateKey(BigInteger primeP) => new BigInteger(Random.Next(1, (int) primeP - 1));

    public static BigInteger PublicKey(BigInteger primeP, BigInteger primeG, BigInteger privateKey) => BigInteger.ModPow(primeG, privateKey, primeP);

    public static BigInteger Secret(BigInteger primeP, BigInteger publicKey, BigInteger privateKey) => BigInteger.ModPow(publicKey, privateKey, primeP);
}

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/csharp/exercises/diffie-hellman/Example.cs
trackler-2.2.1.179 tracks/csharp/exercises/diffie-hellman/Example.cs
trackler-2.2.1.178 tracks/csharp/exercises/diffie-hellman/Example.cs
trackler-2.2.1.177 tracks/csharp/exercises/diffie-hellman/Example.cs
trackler-2.2.1.176 tracks/csharp/exercises/diffie-hellman/Example.cs
trackler-2.2.1.175 tracks/csharp/exercises/diffie-hellman/Example.cs
trackler-2.2.1.174 tracks/csharp/exercises/diffie-hellman/Example.cs
trackler-2.2.1.173 tracks/csharp/exercises/diffie-hellman/Example.cs
trackler-2.2.1.172 tracks/csharp/exercises/diffie-hellman/Example.cs
trackler-2.2.1.171 tracks/csharp/exercises/diffie-hellman/Example.cs
trackler-2.2.1.170 tracks/csharp/exercises/diffie-hellman/Example.cs
trackler-2.2.1.169 tracks/csharp/exercises/diffie-hellman/Example.cs
trackler-2.2.1.167 tracks/csharp/exercises/diffie-hellman/Example.cs
trackler-2.2.1.166 tracks/csharp/exercises/diffie-hellman/Example.cs
trackler-2.2.1.165 tracks/csharp/exercises/diffie-hellman/Example.cs
trackler-2.2.1.164 tracks/csharp/exercises/diffie-hellman/Example.cs
trackler-2.2.1.163 tracks/csharp/exercises/diffie-hellman/Example.cs
trackler-2.2.1.162 tracks/csharp/exercises/diffie-hellman/Example.cs
trackler-2.2.1.161 tracks/csharp/exercises/diffie-hellman/Example.cs
trackler-2.2.1.160 tracks/csharp/exercises/diffie-hellman/Example.cs