Menu

[r101]: / phprpc_2.1 / keygen / keygen.cs  Maximize  Restore  History

Download this file

42 lines (41 with data), 1.3 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.IO;
using Mono.Math;
class keygen
{
static void Main(string[] args)
{
StreamWriter sw = new StreamWriter("keypair.php");
sw.WriteLine("<?php");
sw.WriteLine("$phprpc_keypair = array(");
BigInteger n1 = new BigInteger(1);
BigInteger n2 = new BigInteger(2);
for (int i = 0; i < 100; i++)
{
bool f = false;
BigInteger q = null, p = null, g = null;
while (!f)
{
q = BigInteger.GeneratePseudoPrime(127);
p = q << 1;
p.SetBit(0);
if (p.IsProbablePrime()) f = true;
}
while (f)
{
g = BigInteger.GenerateRandom(127);
if (g.ModPow(n2, p) != n1 && g.ModPow(q, p) != n1)
{
f = false;
}
}
Console.WriteLine("p=" + p.ToString());
Console.WriteLine("g=" + g.ToString());
sw.WriteLine(" array('p' => '" + p.ToString() + "',");
sw.WriteLine(" 'g' => '" + g.ToString() + "'),");
}
sw.WriteLine(");");
sw.Write("?>");
sw.Close();
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.