Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Below is some code that will be useful later.
- //It is a BigInteger square root method and some strings related to and including RSA Challenge number 100. It is the smallest RSA //number, so it is good for examples.
- using System.Numerics;
- namespace IntegerFactorisation
- {
- public static class Lib
- {
- public static string Rsa100c =
- "1522605027922533360535618378132637429718068114961380688657908494580122963258952897654000350692006139";
- public static string Rsa100a = "37975227936943673922808872755445627854565536638199";
- public static string Rsa100b = "40094690950920881030683735292761468389214899724061";
- public static string Rsa100d = "39020571855401265512289573339484371018905006900194";
- public static string Rsa100e = "61218444075812733697456051513875809617598014768503";
- public static string Rsa100f = "16822699634989797327123095165092932420211999031886";//2d+1-e
- public static string Rsa100n = "14387588531011964456730684619177102985211280936";
- public static string Rsa100x = "1045343918457591589480700584038743164339470261995";
- public static string Rsa100x_plus_n = "1059731506988603553937431268657920267324681542931";
- public static BigInteger Sqrt(this BigInteger number)
- {
- BigInteger n = 0, p = 0;
- if (number == BigInteger.Zero)
- {
- return BigInteger.Zero;
- }
- var high = number >> 1;
- var low = BigInteger.Zero;
- while (high > low + 1)
- {
- n = (high + low) >> 1;
- p = n * n;
- if (number < p)
- {
- high = n;
- }
- else if (number > p)
- {
- low = n;
- }
- else
- {
- break;
- }
- }
- return number == p ? n : low;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement