Changeset 1818

Ignore:
Timestamp:
Aug 17, 2010, 12:43:52 AM (11 years ago)
Message:

some renaming

Location:
trunk
Files:
4 edited

Unmodified
Removed
• trunk/CrypPluginBase/Miscellaneous/BigIntegerHelper.cs

 r1816 } private static Stack scan(string expr) private static Stack Scan(string expr) { TOKEN t = new TOKEN(); { case ' ': return scan(expr.Substring(1)); return Scan(expr.Substring(1)); case '(': t.ttype = TOKEN.Ttype.BRACKETOPEN; throw new Exception("Expression parsing failed at character " + expr[0]); } Stack st = scan(expr.Substring(startIndex)); Stack st = Scan(expr.Substring(startIndex)); st.Push(t); return st; private enum Priority { ALL, POW, MULTDIV, ADDSUB }; private static BigInteger parse(Stack stack, Priority priority, bool endbracket) private static BigInteger Parse(Stack stack, Priority priority, bool endbracket) { if (stack.Count == 0) else if (t.ttype == TOKEN.Ttype.BRACKETOPEN) { v = minus * parse(stack, Priority.ALL, true); v = minus * Parse(stack, Priority.ALL, true); stack.Pop();    //pop the closing bracket } return v; stack.Pop(); v = v + parse(stack, Priority.ADDSUB, endbracket); v = v + Parse(stack, Priority.ADDSUB, endbracket); break; case TOKEN.Ttype.MINUS: return v; stack.Pop(); v = v - parse(stack, Priority.ADDSUB, endbracket); v = v - Parse(stack, Priority.ADDSUB, endbracket); break; case TOKEN.Ttype.MULTIPLY: return v; stack.Pop(); v = v * parse(stack, Priority.MULTDIV, endbracket); v = v * Parse(stack, Priority.MULTDIV, endbracket); break; case TOKEN.Ttype.DIVIDE: return v; stack.Pop(); v = v / parse(stack, Priority.MULTDIV, endbracket); v = v / Parse(stack, Priority.MULTDIV, endbracket); break; case TOKEN.Ttype.POW: stack.Pop(); v = BigInteger.Pow(v, (int)parse(stack, Priority.POW, endbracket)); v = BigInteger.Pow(v, (int)Parse(stack, Priority.POW, endbracket)); break; case TOKEN.Ttype.BRACKETCLOSE: * throws an exception when expression is not valid or the Number gets too big */ public static BigInteger parseExpression(string expr) { Stack stack = scan(expr); BigInteger i = parse(stack, Priority.ALL, false); public static BigInteger ParseExpression(string expr) { Stack stack = Scan(expr); BigInteger i = Parse(stack, Priority.ALL, false); return i; } // primes smaller than 2000 to test the generated prime number (taken from BigInteger class written by Chew Keong TAN) public static readonly int[] primesBelow2000 = { private static readonly int[] primesBelow2000 = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, * This code is heavily inspired by the code from the BigInteger class written by Chew Keong TAN */ public static bool isProbablePrime(BigInteger thisVal) public static bool IsProbablePrime(BigInteger thisVal) { thisVal = BigInteger.Abs(thisVal);
• trunk/CrypPlugins/BigNumber/BigNumberInput.cs

 r1448 try { bi = BigIntegerHelper.parseExpression(settings.Number); bi = BigIntegerHelper.ParseExpression(settings.Number); } catch (Exception ex)
• trunk/CrypPlugins/Converter/Converter.cs

 r1448 { BigInteger temp = BigIntegerHelper.parseExpression(inpString); BigInteger temp = BigIntegerHelper.ParseExpression(inpString); Output = temp;
• trunk/CrypPlugins/RSA/RSAKeyGenerator.cs

 r1448 try { p = BigIntegerHelper.parseExpression(settings.P); q = BigIntegerHelper.parseExpression(settings.Q); e = BigIntegerHelper.parseExpression(settings.E); if (!BigIntegerHelper.isProbablePrime(p)) p = BigIntegerHelper.ParseExpression(settings.P); q = BigIntegerHelper.ParseExpression(settings.Q); e = BigIntegerHelper.ParseExpression(settings.E); if (!BigIntegerHelper.IsProbablePrime(p)) { GuiLogMessage(p.ToString() + " is not prime!", NotificationLevel.Error); return; } if (!BigIntegerHelper.isProbablePrime(q)) if (!BigIntegerHelper.IsProbablePrime(q)) { GuiLogMessage(q.ToString() + " is not prime!", NotificationLevel.Error); try { n = BigIntegerHelper.parseExpression(settings.N); d = BigIntegerHelper.parseExpression(settings.D); e = BigIntegerHelper.parseExpression(settings.E); n = BigIntegerHelper.ParseExpression(settings.N); d = BigIntegerHelper.ParseExpression(settings.D); e = BigIntegerHelper.ParseExpression(settings.E); } catch (Exception ex)
Note: See TracChangeset for help on using the changeset viewer.