Exemple #1
1
        /// Read long numbers and initialize parameters
        /// A0 - The right particle of the first part of the number
        /// A1 - The left particle of the first part of the number
        /// B0 - The right particle of the second part of the number
        /// B1 - The left particle of the second part of the number
        /// K - Middle of the numbers
        /// N - Number of bits
        public static void Read(out BigInteger A0, out BigInteger A1,
                                out BigInteger B0, out BigInteger B1,
                                out int K, out int N)
        {
            using (StreamReader sr = new StreamReader("test.txt"))
            {
                string a, a0, a1, b, b0, b1;
                a = sr.ReadLine();
                b = sr.ReadLine();

                K = a.Length / 2;
                N = a.Length;

                // making strings to parse
                a0 = a.Substring(0, K);
                a1 = a.Substring(K);
                b0 = b.Substring(0, K);
                b1 = b.Substring(K);

                A0 = BigInteger.Parse(a1);
                A1 = BigInteger.Parse(a0);
                B0 = BigInteger.Parse(b1);
                B1 = BigInteger.Parse(b0);
            }

        }
        /// <summary>
        /// 其他场景的动物栏收益和
        /// </summary>
        /// <param name="isNeedMulBuff"></param>
        /// <returns></returns>
        public static System.Numerics.BigInteger GetOtherSceneAllZooPrice(int sceneID, bool isNeedMulBuff = false)
        {
            int   parkNumber      = ParkingCenter.GetOtherSceneParkingEnterCarSpawn(sceneID);
            float entryGateNumber = EntryGateModule.GetAllEntryChargeValMs(sceneID);

            //LogWarp.LogErrorFormat("其他场景 停车场来人速度{0}  售票口收费速度{1}", parkNumber, entryGateNumber);

            System.Numerics.BigInteger littleZooNumber = 0;

            PlayerData playerData = GlobalDataManager.GetInstance().playerData;
            var        littleZooModuleDataList_MS = GlobalDataManager.GetInstance().playerData.playerZoo.littleZooModuleDatasMSS;

            //int sceneID = GlobalDataManager.GetInstance().playerData.playerZoo.currSceneID;
            for (int i = 0; i < littleZooModuleDataList_MS.Count; i++)
            {
                if (littleZooModuleDataList_MS[i].littleZooTicketsLevel == 0 || littleZooModuleDataList_MS[i].sceneID != sceneID)
                {
                    continue;
                }
                //每分钟动物栏基础收益=动物栏产出*min(停车场来人速度,售票口收费速度(全),60/(观光速度*观光点数))
                //动物栏产出
                var number1 = LittleZooModule.GetLittleZooPrice(littleZooModuleDataList_MS[i].littleZooID, littleZooModuleDataList_MS[i].littleZooTicketsLevel, isNeedMulBuff);
                //观光速度*观光点数
                var number4 = LittleZooModule.GetLittleZooVisitorNumberMS(littleZooModuleDataList_MS[i].littleZooID, littleZooModuleDataList_MS[i]);
                var number5 = (int)(Mathf.Min(parkNumber, entryGateNumber, number4)) * number1;
                //LogWarp.LogErrorFormat("测试:非 parkNumber={0} entryGateNumber={1} number4={2} number1={3} ",parkNumber, entryGateNumber, number4,number1);
                littleZooNumber += number5;
            }
            return(littleZooNumber);
        }
Exemple #3
0
        void FactorialRecursion()
        {
            DateTime   StartTimeRecursion = DateTime.Now;
            BigInteger FactorialRecursion = new System.Numerics.BigInteger();

            //BigInteger i = new System.Numerics.BigInteger();//аккуратнее, в цикле используется ++, если будут ошибки заменить на BigInteger.Add(BigInt,BigInt)
            if (checkBox_Recursion.Checked == true)
            {
                FactorialRecursion = factorial(number);
            }
            else
            {
                for (int i = 1; i <= number; i++)
                {
                    if (i == 1)
                    {
                        FactorialRecursion = 1;
                    }
                    else
                    {
                        FactorialRecursion *= i;
                    }
                }
            }
            DateTime EndTimeRecursion = DateTime.Now;

            ResultString += "Calculation time with Threading (recursion): " + (EndTimeRecursion - StartTimeRecursion).ToString("g") + Environment.NewLine;
            //richTextBoxResult.Text += Convert.ToString(FactorialRecursion); //закомментим вывод числа
        }
        public static string decimal_to_base64(string content)
        {
            try
            {
                string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

                string result = "";

                System.Numerics.BigInteger content_int = System.Numerics.BigInteger.Parse(content);
                while (true)
                {
                    result     += alphabet[(int)content_int % 64].ToString();
                    content_int = content_int / 64;

                    if (content_int <= 0)
                    {
                        break;
                    }
                    else if (content_int < 64)
                    {
                        result += alphabet[(int)content_int].ToString();
                        break;
                    }
                }

                return(string_reverse(result));
            }
            catch (Exception e)
            {
                return("");
            }
        }
        public static string decimal_to_base32(string content)
        {
            try
            {
                string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";

                string result = "";

                System.Numerics.BigInteger content_int = System.Numerics.BigInteger.Parse(content);
                while (true)
                {
                    result     += alphabet[(int)content_int % 32].ToString();
                    content_int = content_int / 32;

                    if (content_int <= 0)
                    {
                        break;
                    }
                    else if (content_int < 32)
                    {
                        result += alphabet[(int)content_int].ToString();
                        break;
                    }
                }

                return(string_reverse(result));
            }
            catch (Exception e)
            {
                return("");
            }
        }
Exemple #6
0
            //prioritize digits at digit depth
            private Digit[] orderDigits(int depth)
            {
                Digit[] d = new Digit[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

                BigInteger[] products = new BigInteger[10];
                BigInteger[] ordered = new BigInteger[10];

                for(int i = 0; i < 10; i++)
                {
                    index[depth] = (Byte)d[i];
                    setNums(depth);
                    products[i] = nums[0].Value * nums[1].Value;
                }

                for (int i = 0; i < 10; i++)
                  ordered[i] = products[i];

                Array.Sort(ordered);

                for (int i = 0; i < 10; i++)
                {
                    for(int j = 0; j < 10; j++)
                    {
                        if (products[i] == ordered[j])
                            d[i] = j;
                    }
                }

                return d;
            }
Exemple #7
0
        public BigInteger GetSum()
        {
            this.MakeSum(this.Root);
            this.Sum = 0;

            return this.Sum;
        }
Exemple #8
0
        private static bool IsSqrt(BigInteger n, BigInteger root)
        {
            var lowerBound = root * root;
            var upperBound = (root + 1) * (root + 1);

            return (n >= lowerBound && n < upperBound);
        }
        public static string decimal_to_binary(string content)
        {
            try
            {
                string result = "";

                System.Numerics.BigInteger content_int = System.Numerics.BigInteger.Parse(content);
                while (true)
                {
                    result     += (content_int % 2).ToString();
                    content_int = content_int / 2;

                    if (content_int == 0)
                    {
                        break;
                    }
                }

                return(string_reverse(result));
            }
            catch (Exception e)
            {
                return("");
            }
        }
        public Integer Evaluate(Integer n)
        {
            var xmax = IntegerMath.FloorSquareRoot(n);
            var s    = Evaluate(n, 1, (long)xmax);

            return(2 * s - xmax * xmax);
        }
Exemple #11
0
        public string ConvertHexToDec(string hex)
        {
            var result     = _hexReader.ToByteArray(hex, Endian.Big).ToArray();
            var bigInteger = new System.Numerics.BigInteger(result);

            return(bigInteger.ToString());
        }
        /// <summary>
        /// Verify.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <param name="serial">The serial.</param>
        /// <returns></returns>
        public override bool Verify(Stream input, string serial = null)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }
            using (var package = Package.Open(input, FileMode.Open, FileAccess.Read))
            {
                var mgr = new PackageDigitalSignatureManager(package)
                {
                    CertificateOption = CertificateEmbeddingOption.InSignaturePart
                };

                var result = false;
                foreach (var sig in mgr.Signatures)
                {
                    var verifyResult = mgr.VerifySignatures(true);
                    result = verifyResult == VerifyResult.Success;
                    if (result && !String.IsNullOrWhiteSpace(serial))
                    {
                        var actualSerial = new BigInteger(sig.Signer.GetSerialNumber());
                        var expectedSerial = CertUtil.HexadecimalStringToBigInt(serial);
                        result = actualSerial == expectedSerial;
                    }
                }
                package.Close();
                return result;
            }
        }
 private BigInteger factorial(int i, BigInteger total)
 {
     if (i <= 1)
         return total;
     BigInteger newTotal = total * i;
     return factorial(i - 1, newTotal);
 }
Exemple #14
0
            private sysnum.BigInteger simHash()
            {
                int[]        v            = new int[this.hashbits];
                ChxTokenizer stringTokens = new ChxTokenizer(this.tokens);

                while (stringTokens.hasMoreTokens())
                {
                    String            temp = stringTokens.nextToken();
                    sysnum.BigInteger t    = this.hash(temp);
                    //Console.WriteLine("temp = {0} : {1}", temp, t);
                    for (int i = 0; i < this.hashbits; i++)
                    {
                        sysnum.BigInteger bitmask = sysnum.BigInteger.One << i;
                        if ((t & bitmask).Sign != 0)
                        {
                            v[i] += 1;
                        }
                        else
                        {
                            v[i] -= 1;
                        }
                    }
                }
                sysnum.BigInteger fingerprint = sysnum.BigInteger.Zero;
                for (int i = 0; i < this.hashbits; i++)
                {
                    if (v[i] >= 0)
                    {
                        fingerprint = fingerprint + (sysnum.BigInteger.Parse("1") << i);
                    }
                }
                return(fingerprint);
            }
        /// <summary>
        /// Converts a <see cref="BigInteger"/> to its equivalent string representation that is encoded with base digits specified.
        /// </summary>
        /// <param name="value">A <see cref="BigInteger"/> that will be encoded.</param>
        /// <param name="baseDigits">The base digits used to encode with.</param>
        /// <returns>The string representation, in base digits, of the contents of <paramref name="value"/>.</returns>
        public static string ToBaseString(BigInteger value, string baseDigits)
        {
            if (baseDigits == null)
                throw new ArgumentNullException("baseDigits");
            if (baseDigits.Length < 2)
                throw new ArgumentOutOfRangeException("baseDigits", "Base alphabet must have at least two characters.");

            // same functionality as Convert.ToBase64String
            if (value == BigInteger.Zero)
                return string.Empty;

            bool isNegative = value.Sign == -1;
            value = isNegative ? -value : value;

            int length = baseDigits.Length;
            var result = new Stack<char>();

            do
            {
                BigInteger remainder;
                value = BigInteger.DivRem(value, length, out remainder);
                result.Push(baseDigits[(int)remainder]);
            } while (value > 0);


            // if the number is negative, add the sign.
            if (isNegative)
                result.Push('-');

            // reverse it
            return new string(result.ToArray());
        }
 public static BigInteger RetrievePrivateKey(string path)
 {
     var bytes = File.ReadAllBytes(@"" + path);
     var privateKey = new BigInteger(bytes);
     Console.WriteLine("D: " + privateKey);
     return privateKey;
 }
Exemple #17
0
        private Integer CountPoints(Integer max, Integer c1, Integer c2, Integer coef, Integer denom)
        {
            // Count points under the hyperbola:
            // (x0 - b1*v + b2*u)*(y0 + a1*v - a2*u) = n
            // Horizontal: For u = 1 to max calculate v in terms of u.
            // vertical: For v = 1 to max calculate u in terms of v.
            // Note that there are two positive solutions and we
            // take the smaller of the two, the one nearest the axis.
            // By being frugal we can re-use most of the calculation
            // from the previous point.

            // We use the identity (a >= 0, b >= 0, c > 0; a, b, c elements of Z):
            // floor((b-sqrt(a)/c) = floor((b-ceiling(sqrt(a)))/c)
            // to enable using integer arithmetic.

            // Formulas:
            // v = ((a1*b2+a2*b1)*(u+c1)-sqrt((u+c1)^2-4*a1*b1*n))/(2*a1*b1)-c2
            // u = ((a1*b2+a2*b1)*(v+c2)-sqrt((v+c2)^2-4*a2*b2*n))/(2*a2*b2)-c1
            var sum = (Integer)0;
            var a   = c1 * c1 - 2 * denom * n;
            var b   = c1 * coef;
            var da  = 2 * c1 - 1;

            for (var i = (Integer)1; i < max; i++)
            {
                da  += 2;
                a   += da;
                b   += coef;
                sum += (b - IntegerMath.CeilingSquareRoot(a)) / denom;
            }
            return(sum - (max - 1) * c2);
        }
Exemple #18
0
        /// <summary>
        /// Creates a new ResultSequence consisting of the extractable integer in the
        /// supplied ResultSequence
        /// </summary>
        /// <param name="arg">
        ///            The ResultSequence from which the integer is to be extracted </param>
        /// <returns> New ResultSequence consisting of the integer supplied </returns>
        /// <exception cref="DynamicError"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.eclipse.wst.xml.xpath2.api.ResultSequence constructor(org.eclipse.wst.xml.xpath2.api.ResultSequence arg) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public override ResultSequence constructor(ResultSequence arg)
        {
            if (arg.empty())
            {
                return(ResultBuffer.EMPTY);
            }

            // the function conversion rules apply here too. Get the argument
            // and convert it's string value to an integer.
            Item aat = arg.first();

            if (aat is XSDuration || aat is CalendarType || aat is XSBase64Binary || aat is XSHexBinary || aat is XSAnyURI)
            {
                throw DynamicError.invalidType();
            }

            if (!isCastable(aat))
            {
                throw DynamicError.cant_cast(null);
            }


            try
            {
                System.Numerics.BigInteger bigInt = castInteger(aat);
                return(new XSInteger(bigInt));
            }
            catch (System.FormatException)
            {
                throw DynamicError.invalidLexicalValue();
            }
        }
Exemple #19
0
        bool IsMagic(BI A1, BI A2, BI A3, BI B1, BI B2, BI B3, BI C1, BI C2, BI C3, int Exp = 2)
        {
            if (Compare(A1, A2, A3, B1, B2, B3, C1, C2, C3))
            {
                return(false);
            }

            /*A1 = BigInteger.Pow(A1, Exp);
            *  A2 = BigInteger.Pow(A2, Exp);
            *  A3 = BigInteger.Pow(A3, Exp);
            *  B1 = BigInteger.Pow(B1, Exp);
            *  B2 = BigInteger.Pow(B2, Exp);
            *  B3 = BigInteger.Pow(B3, Exp);
            *  C1 = BigInteger.Pow(C1, Exp);
            *  C2 = BigInteger.Pow(C2, Exp);
            *  C3 = BigInteger.Pow(C3, Exp);*/

            BigInteger Expected = A1 + A2 + A3;

            if ((B1 + B2 + B3) == Expected)
            {
                if ((C1 + C2 + C3) == Expected)
                {
                    if ((A1 + B2 + C3) == Expected)
                    {
                        if ((C1 + B2 + A3) == Expected)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Exemple #20
0
 public ScriptBuilder Push(BigInteger number)
 {
     if (number == -1) return Add(ScriptOp.OP_1NEGATE);
     if (number == 0) return Add(ScriptOp.OP_0);
     if (number > 0 && number <= 16) return Add(ScriptOp.OP_1 - 1 + (byte)number);
     return Push(number.ToByteArray());
 }
Exemple #21
0
 public ChainedHeader(BlockHeader blockHeader, int height, BigInteger totalWork, DateTimeOffset dateSeen)
 {
     BlockHeader = blockHeader;
     Height = height;
     TotalWork = totalWork;
     DateSeen = dateSeen;
 }
        private static BigInteger Solve(List<int> parties, int k)
        {
            var sums = new BigInteger[parties.Sum() + 1];
            sums[0] = 1;
            var maxSum = 0;

            for (int i = 0; i < parties.Count; i++)
            {
                var number = parties[i];
                for (int j = maxSum; j >= 0; j--)
                {
                    if (sums[j] > 0)
                    {
                        sums[j + number] += sums[j];
                        maxSum = Math.Max(j + number, maxSum);
                    }
                }
            }

            BigInteger combinations = 0;
            for (int i = k; i <= parties.Sum(); i++)
            {
                combinations += sums[i];
            }

            return combinations;
        }
 private string DoConvertationFirstStage(BigInteger number)
 {
     if (number == 0)
         return "0";
     else
         return DoConvertation(number);
 }
Exemple #24
0
        private void Initialize(bool ignoreBaseKeys = false)
        {
            PublicKey = 0;

            Random rand = new Random();
            while (PublicKey == 0)
            {
                if (!ignoreBaseKeys)
                {
                    Prime = PrimeCalculator.GenPseudoPrime(Bitlength, 10, rand);
                    Generator = PrimeCalculator.GenPseudoPrime(Bitlength, 10, rand);
                }

                byte[] bytes = new byte[Bitlength/8];
                Randomizer.NextBytes(bytes);
                _privateKey = new BigInteger(bytes);

                if (_privateKey < 1)
                    continue;

                if (Generator > Prime)
                {
                    BigInteger temp = Prime;
                    Prime = Generator;
                    Generator = temp;
                }

                PublicKey = BigInteger.ModPow(Generator, _privateKey, Prime);

                if (!ignoreBaseKeys)
                    break;
            }
        }
        static void Main(string[] args)
        {

            string titel = "SumFibonacci";
            string problem = @"Write a program that reads a number N and calculates the sum of the first N members of the sequence of Fibonacci: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, …
1. Each member of the Fibonacci sequence (except the first two) is a sum of the previous two members.";

            Console.WriteLine("Title:   " + titel + "\n" + "Problem: " + problem);

            int N;
            Console.Write("Please enter N (N > 0):");
            bool isNint = int.TryParse(Console.ReadLine(), out N);
            BigInteger[] arr = new BigInteger[N + 1];
            arr[0] = 1;
            arr[1] = 1;
            if (isNint && N > 0)
            {
                for (int i = 2; i < N; i++)
                {
                    arr[i] = arr[i - 2] + arr[i - 1];
                }
            }
            else
            {
                Console.WriteLine("Invalide input");
            }
            Console.WriteLine("The {0} Fibonacci member is: {1}", N, arr[N - 1]);
        }
        /// <summary>
        /// Determines whether BigInteger is prime number with probability that can be greater than requested probability
        /// </summary>
        /// <param name="number">The BigInteger to check</param>
        /// <param name="probability">Probability of error</param>
        /// <returns></returns>
        public bool IsPrime(BigInteger number, BigNumDec probability)
        {
            if (probability.Equals(0) || probability.Equals(1))
                throw new ArgumentException("Probability must be in range (0; 1)");

            int iterations = 1;
            BigNum baseNum = 0.25;
            while (true)
            {
                if (baseNum <= probability)
                    break;

                baseNum *= 0.25;
                iterations++;
            }

            while (iterations > 0)
            {
                if (!IsPrime(number))
                    return false;

                --iterations;
            }

            return true;
        }
        public void Generate_ab()
        {
            byte[] bytes = new byte[KeySize / 8];
            BigInteger _a = new BigInteger(bytes);

            RandomNumberGenerator rng = RandomNumberGenerator.Create();
            while (!_a.IsProbablePrime(KeySize) || _a >= P)
            {
                rng.GetBytes(bytes);

                byte[] temp = new byte[bytes.Length + 1];
                Array.Copy(bytes, temp, bytes.Length);

                _a = new BigInteger(temp);
            }

            bytes = new byte[KeySize / 8];
            BigInteger _b = new BigInteger(bytes);
            while (!_b.IsProbablePrime(KeySize) || _b >= P)
            {
                rng.GetBytes(bytes);

                byte[] temp = new byte[bytes.Length + 1];
                Array.Copy(bytes, temp, bytes.Length);

                _b = new BigInteger(temp);
            }

            a = _a;
            b = _b;
        }
Exemple #28
0
        public static int[] FindIthPermutation(int n, BigInteger i)
        {
            BigInteger[] fact = new BigInteger[n];
            int[] permutation = new int[n];

            fact[0] = 1;
            for (int k = 1; k < n; k++)
            {
                fact[k] = fact[k - 1] * k;
            }

            for (int k = 0; k < n; k++)
            {
                permutation[k] = (int)BigInteger.Divide(i, fact[n - 1 - k]);
                i = i % fact[n - 1 - k];
            }

            for (int k = n - 1; k > 0; k--)
            {
                for (int j = k - 1; j >= 0; j--)
                {
                    if (permutation[j] <= permutation[k])
                        permutation[k]++;
                }
            }

            for (int k = 0; k < n; k++)
            {
                permutation[k]++;
            }

            return permutation;
        }
Exemple #29
0
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int dn   = 2 * n;
            int nOne = n + 1;

            System.Numerics.BigInteger dnFac   = 1;
            System.Numerics.BigInteger noneFac = 1;
            System.Numerics.BigInteger nFac    = 1;
            for (int f = 1; f <= dn; f++)
            {
                dnFac = dnFac * f;
            }
            for (int i = 1; i <= nOne; i++)
            {
                noneFac = noneFac * i;
            }
            for (int j = 1; j <= n; j++)
            {
                nFac = nFac * j;
            }
            System.Numerics.BigInteger cn = dnFac / (noneFac * nFac);
            Console.WriteLine(cn);
        }
        public static string decimal_to_hexadecimal(string content)
        {
            try
            {
                string alphabet = "0123456789ABCDEF";

                string result = "";

                System.Numerics.BigInteger content_int = System.Numerics.BigInteger.Parse(content);
                while (true)
                {
                    result     += alphabet[(int)content_int % 16].ToString();
                    content_int = content_int / 16;

                    if (content_int <= 0)
                    {
                        break;
                    }
                    else if (content_int < 16)
                    {
                        result += alphabet[(int)content_int].ToString();
                        break;
                    }
                }

                return(string_reverse(result));
            }
            catch (Exception e)
            {
                return("");
            }
        }
Exemple #31
0
        // Token: 0x06000E7C RID: 3708 RVA: 0x00056FD8 File Offset: 0x000551D8
        public static object FromBigInteger(System.Numerics.BigInteger i, Type targetType)
        {
            if (targetType == typeof(decimal))
            {
                return((decimal)i);
            }
            if (targetType == typeof(double))
            {
                return((double)i);
            }
            if (targetType == typeof(float))
            {
                return((float)i);
            }
            if (targetType == typeof(ulong))
            {
                return((ulong)i);
            }
            if (targetType == typeof(bool))
            {
                return(i != 0L);
            }
            object result;

            try
            {
                result = System.Convert.ChangeType((long)i, targetType, CultureInfo.InvariantCulture);
            }
            catch (Exception innerException)
            {
                throw new InvalidOperationException("Can not convert from BigInteger to {0}.".FormatWith(CultureInfo.InvariantCulture, targetType), innerException);
            }
            return(result);
        }
Exemple #32
0
        public virtual bool checkIfNumberIsCorrect(string cardNumber)
        {
            if (cardNumber.Length > 9)
            {
                string cardNumberType = (cardNumber.Length > 26 ? "IBAN" : "NRB");

                if (cardNumberType.Equals("NRB"))
                    cardNumber = "PL" + cardNumber;

                BigInteger test = new BigInteger();
                string sCopy = cardNumber.Substring(4, cardNumber.Length - 4) + cardNumber.Substring(0, 4);

                for (int a = 0; a <= sCopy.Length - 1; a++)
                {
                    if (sCopy[a] >= 'A' && sCopy[a] <= 'Z')
                        sCopy = sCopy.Replace(sCopy[a].ToString(), ((int)(sCopy[a]) - 55).ToString());
                    if (sCopy[a] >= 'a' && sCopy[a] <= 'z')
                        sCopy = sCopy.Replace(sCopy[a].ToString(), ((int)(sCopy[a]) - 87).ToString());
                }

                test = BigInteger.Parse(sCopy);

                test %= 97;
                return (test.ToString().Equals("1") ? true : false);
            }
            else return false;
        }
 /// <summary>
 /// Инициализирует машину Поста пустой лентой.
 /// </summary>
 public PostMachine()
 {
     _tape = new Tape(TapeType.TwoStated);
     _pos = 0;
     _ops = null;
     _opNum = 0;
 }
        public static void ReadIntegers()
        {
            byte[] derEncoded =
            {
                /* SEQUENCE */     0x30, 23,
                /* INTEGER(0) */   0x02, 0x01, 0x00,
                /* INTEGER(256) */ 0x02, 0x02, 0x01, 0x00,
                /* INTEGER(-1) */  0x02, 0x01, 0xFF,
                /* Big integer */  0x02, 0x0B, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
            };

            DerSequenceReader reader = new DerSequenceReader(derEncoded);
            Assert.True(reader.HasData);
            Assert.Equal(23, reader.ContentLength);

            int first = reader.ReadInteger();
            Assert.Equal(0, first);

            int second = reader.ReadInteger();
            Assert.Equal(256, second);

            int third = reader.ReadInteger();
            Assert.Equal(-1, third);

            // Reader reads Big-Endian, BigInteger reads Little-Endian
            byte[] fourthBytes = reader.ReadIntegerBytes();
            Array.Reverse(fourthBytes);
            BigInteger fourth = new BigInteger(fourthBytes);
            Assert.Equal(BigInteger.Parse("3645759592820458633497613"), fourth);

            // And... done.
            Assert.False(reader.HasData);
        }
        public void GeneratePG()
        {
            byte[] bytes = new byte[KeySize / 8];
            BigInteger p = new BigInteger(bytes);

            RandomNumberGenerator rng = RandomNumberGenerator.Create();
            while (!p.IsProbablePrime(KeySize))
            {
                rng.GetBytes(bytes);

                byte[] temp = new byte[bytes.Length + 1];
                Array.Copy(bytes, temp, bytes.Length);

                p = new BigInteger(temp);
            }

            bytes = new byte[KeySize / 8];
            BigInteger g = new BigInteger(bytes);
            while (!g.IsProbablePrime(KeySize) || g >= p)
            {
                rng.GetBytes(bytes);

                byte[] temp = new byte[bytes.Length + 1];
                Array.Copy(bytes, temp, bytes.Length);

                g = new BigInteger(temp);
            }

            P = p;
            G = g;
        }
Exemple #36
0
        private static void TestMatrixMultiply(int n)
        {
            Console.WriteLine("Test matrix multiply - Loop (n^3) -> Strassen Algorithm (n^log7 or n^2.81):");
            var st      = new Stopwatch();
            var matrix2 = new BigIntegerMatrix(new System.Numerics.BigInteger[n][]);

            for (var i = 0; i < n; i++)
            {
                matrix2[i] = new System.Numerics.BigInteger[n];
                for (var j = 0; j < n; j++)
                {
                    matrix2[i][j] = new Random(i * j).Next(100);
                }
            }

            st.Restart();
            var resultMat = matrix2 * matrix2;

            st.Stop();
            Print(resultMat.AsEnumerable());
            Console.WriteLine(st.ElapsedMilliseconds);

            st.Restart();
            resultMat = BigIntegerMatrix.StrassenMultiply(matrix2, matrix2);
            st.Stop();
            Print(resultMat.AsEnumerable());
            Console.WriteLine(st.ElapsedMilliseconds);
        }
        private bool MRtest(ref BigInteger number)
        {
            uint w;
            BigInteger z;

            MRscomposition(ref number, out w, out z);

            bool ris = true;
            uint i = 0;


            while (ris && i < _precision)
            {
                //extract a random number
                _generator.NextBytes(_buffer);
                _buffer[_buffer.Length - 1] &= 127; //forces a positive number
                var y = new BigInteger(_buffer);
                ////
                y = y%number;
                while (y < 2) //avoids extraction of 0 and 1
                {
                    y += _generator.Next();
                    y = y%number;
                }
                //test
                ris = (BigInteger.GreatestCommonDivisor(y, number) == 1) &&
                      (MRpredicate1(ref y, ref z, ref number) || MRpredicate2(ref y, ref number, ref z, w));
                i++;
            }
            return ris;
        }
Exemple #38
0
        public void Execute()
        {
            //это сам алгоритм
            _factorial = 1;
            for (int i = _number1; i < _number2 + 1; i++)
            {
                _factorial *= i;
            }

            Data = _factorial.ToString();

            if (/*_myClientNumber < _highestClientNumber &&*/ _myClientNumber != 0)
            {
                var incomingPackage = _internalPackageProvider.GetPackage();
                var firstMult = BigInteger.Parse(incomingPackage.Data);
                _factorial *= firstMult;
            }
            if (_myClientNumber < _highestClientNumber)
            {
                formPackage(_factorial.ToString(),_myClientNumber+1);
                OnSend();
            }

            if (_myClientNumber == _highestClientNumber)
            {
                formPackage(_factorial.ToString(), -1);
                OnReady();
            }
        }
Exemple #39
0
        public int Solve()
        {
            BigInteger max = -1;
            int result = -1;

            for (int i = 1; i <= limit; i++) {
                int root = (int)Math.Sqrt(i);
                if (root * root != i) {
                    ContinuedFraction fraction = new ContinuedFraction(i);
                    bool found = false;
                    BigInteger[] next = new BigInteger[] { 0 };
                    while (!found) {
                        next = fraction.GetNext();
                        if(next[0] * next[0] - i * next[1] * next[1] == 1) {
                            found = true;
                        }
                    }

                    if(max < next[0]) {
                        max = next[0];
                        result = i;
                    }
                }
            }
            return result;
        }
Exemple #40
0
        public FibonacciResultSet Compute(int len)
        {
            if (len < 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            var results = new BigInteger[len];

            // zero case
            if (len == 0)
            {
                return new FibonacciResultSet { Results = results };
            }

            // one case
            results[0] = 0;
            if (len == 1)
            {
                return new FibonacciResultSet { Results = results };
            }

            // compute values
            results[1] = 1;
            for (int i = 2; i < len; i++)
            {
                results[i] = results[i - 1] + results[i - 2];
            }

            FibonacciResultSet resultSet = new FibonacciResultSet { Results = results };

            return resultSet;
        }
Exemple #41
0
        public SRP6a(string salt, string accountName = "", string passwordVerifier = "")
        {
            sha256 = new SHA256Managed();

            I = sha256.ComputeHash(Encoding.UTF8.GetBytes(accountName));

            N = new byte[]
            {
                0xE3, 0x06, 0xEB, 0xC0, 0x2F, 0x1D, 0xC6, 0x9F, 0x5B, 0x43, 0x76, 0x83, 0xFE, 0x38, 0x51, 0xFD,
                0x9A, 0xAA, 0x6E, 0x97, 0xF4, 0xCB, 0xD4, 0x2F, 0xC0, 0x6C, 0x72, 0x05, 0x3C, 0xBC, 0xED, 0x68,
                0xEC, 0x57, 0x0E, 0x66, 0x66, 0xF5, 0x29, 0xC5, 0x85, 0x18, 0xCF, 0x7B, 0x29, 0x9B, 0x55, 0x82,
                0x49, 0x5D, 0xB1, 0x69, 0xAD, 0xF4, 0x8E, 0xCE, 0xB6, 0xD6, 0x54, 0x61, 0xB4, 0xD7, 0xC7, 0x5D,
                0xD1, 0xDA, 0x89, 0x60, 0x1D, 0x5C, 0x49, 0x8E, 0xE4, 0x8B, 0xB9, 0x50, 0xE2, 0xD8, 0xD5, 0xE0,
                0xE0, 0xC6, 0x92, 0xD6, 0x13, 0x48, 0x3B, 0x38, 0xD3, 0x81, 0xEA, 0x96, 0x74, 0xDF, 0x74, 0xD6,
                0x76, 0x65, 0x25, 0x9C, 0x4C, 0x31, 0xA2, 0x9E, 0x0B, 0x3C, 0xFF, 0x75, 0x87, 0x61, 0x72, 0x60,
                0xE8, 0xC5, 0x8F, 0xFA, 0x0A, 0xF8, 0x33, 0x9C, 0xD6, 0x8D, 0xB3, 0xAD, 0xB9, 0x0A, 0xAF, 0xEE
            };

            S = salt.ToByteArray();

            g = new byte[] { 2 };

            BN = N.ToBigInteger();
            gBN = g.ToBigInteger();

            k = sha256.ComputeHash(N.Combine(g.Fill32Bits())).ReverseUInt32().ToBigInteger();
            v = passwordVerifier.ToByteArray().ToBigInteger();
        }
Exemple #42
0
        private void Part2()
        {
            /*
             *  Right 1, down 1.
             *  Right 3, down 1. (This is the slope you already checked.)
             *  Right 5, down 1.
             *  Right 7, down 1.
             *  Right 1, down 2.
             */
            DateTime time = System.DateTime.Now;

            int val1 = getTrees(1, 1);
            int val2 = getTrees(1, 3);
            int val3 = getTrees(1, 5);
            int val4 = getTrees(1, 7);
            int val5 = getTrees(2, 1);

            System.Numerics.BigInteger result = val1;
            result *= val2;
            result *= val3;
            result *= val4;
            result *= val5;

            double asd = (System.DateTime.Now - time).TotalMilliseconds;

            Console.WriteLine("Result: " + val1 + " * " + val2 + " * " + val3 + " * " + val4 + " * " + val5 + " = " + result);
            Console.WriteLine("ms needed: " + asd);
            Console.ReadKey();
        }
Exemple #43
0
        public static Blockchain RandomBlockchain(RandomDataOptions options = default(RandomDataOptions))
        {
            //TODO blockCount algorithm isn't exact
            var blockCount = random.Next((options != null ? options.BlockCount : null) ?? 100) + ((options != null ? options.MinimumBlockCount : null) ?? 1);
            var blockList = new List<Block>(blockCount);
            var chainedBlockList = new List<ChainedBlock>(blockCount);

            var previousBlockHash = UInt256.Zero;
            var totalWork = new BigInteger(0);
            for (var i = 0; i < blockCount; i++)
            {
                var block = RandomData.RandomBlock(options);
                block = block.With(Header: block.Header.With(PreviousBlock: previousBlockHash));
                blockList.Add(block);

                previousBlockHash = block.Hash;
                totalWork += block.Header.CalculateWork();

                chainedBlockList.Add(new ChainedBlock(block.Hash, block.Header.PreviousBlock, i, totalWork));
            }

            var blockListHashes = blockList.Select(x => x.Hash).ToImmutableHashSet();
            var utxo = blockList.SelectMany(block =>
                block.Transactions.Select((tx, txIndex) =>
                    new UnspentTx(block.Hash, (UInt32)txIndex, tx.Hash, random.NextImmutableBitArray((options != null ? options.TxOutputCount : null) ?? 100))))
                .ToImmutableDictionary(unspentTx => unspentTx.TxHash, unspentTx => unspentTx);

            return new Blockchain
            (
                chainedBlockList.ToImmutableList(),
                blockListHashes,
                utxo
            );
        }
        public static BigInteger GetBigIntegerFromCompact(uint nCompact)
        {
            uint nSize     =  nCompact >> 24;
            bool fNegative = (nCompact & 0x00800000) != 0;
            uint nWord     =  nCompact & 0x007fffff;

            BigInteger result;

            if (nSize <= 3)
            {
                nWord >>= (int)(8 * (3 - nSize));
                result = new BigInteger (nWord);
            }
            else
            {
                result = new BigInteger (nWord);
                result <<= (int)(8 * (nSize - 3));
            }

            if (fNegative)
            {
                result = result * -1;
            }

            //			Console.WriteLine ("Given:  {0} {1}", nCompact, Utilities.GetBytesString(BitConverter.GetBytes(nCompact), false));
            //			Console.WriteLine ("nSize:  {0} {1}", nSize, Utilities.GetBytesString(BitConverter.GetBytes(nSize), false));
            //			Console.WriteLine ("nWord:  {0} {1}", nWord, Utilities.GetBytesString(BitConverter.GetBytes(nWord), false));
            //			Console.WriteLine ("isNeg:  {0}", fNegative.ToString());
            //			Console.WriteLine ("Result: {0} {1}", result, Utilities.GetBytesString (result.ToByteArray (), false));

            return result;
        }
Exemple #45
0
 public BigInteger GetElementValue(BigInteger divisor, BigInteger position)
 {
     if (divisor == DefaultElement)
     {
         if (position <= _seriesX.Count)
         {
             return DefaultElement;
         }
         _initialPosition = new BigInteger(_seriesX.Count+1);
     }
     while (true)
     {
         var element = _seriesX.Aggregate(BigInteger.Add);
         if (element % divisor == 0)
         {
             if (_initialPosition == position)
             {
                 return element;
             }
             _initialPosition++;
         }
         _seriesX.Dequeue();
         _seriesX.Enqueue(element);
     }
 }
Exemple #46
0
        public DiffieHellman(BigInteger prime, BigInteger generator)
        {
            Prime = prime;
            Generator = generator;

            Initialize(true);
        }
        // Token: 0x06000D8F RID: 3471 RVA: 0x00054F70 File Offset: 0x00053170
        private void ValidateInteger(JsonSchemaModel schema)
        {
            if (schema == null)
            {
                return;
            }
            if (!this.TestType(schema, JsonSchemaType.Integer))
            {
                return;
            }
            this.ValidateNotDisallowed(schema);
            object value = this._reader.Value;

            if (schema.Maximum != null)
            {
                if (JValue.Compare(JTokenType.Integer, value, schema.Maximum) > 0)
                {
                    this.RaiseError("Integer {0} exceeds maximum value of {1}.".FormatWith(CultureInfo.InvariantCulture, value, schema.Maximum), schema);
                }
                if (schema.ExclusiveMaximum && JValue.Compare(JTokenType.Integer, value, schema.Maximum) == 0)
                {
                    this.RaiseError("Integer {0} equals maximum value of {1} and exclusive maximum is true.".FormatWith(CultureInfo.InvariantCulture, value, schema.Maximum), schema);
                }
            }
            if (schema.Minimum != null)
            {
                if (JValue.Compare(JTokenType.Integer, value, schema.Minimum) < 0)
                {
                    this.RaiseError("Integer {0} is less than minimum value of {1}.".FormatWith(CultureInfo.InvariantCulture, value, schema.Minimum), schema);
                }
                if (schema.ExclusiveMinimum && JValue.Compare(JTokenType.Integer, value, schema.Minimum) == 0)
                {
                    this.RaiseError("Integer {0} equals minimum value of {1} and exclusive minimum is true.".FormatWith(CultureInfo.InvariantCulture, value, schema.Minimum), schema);
                }
            }
            if (schema.DivisibleBy != null)
            {
                bool flag;
                if (value is System.Numerics.BigInteger)
                {
                    System.Numerics.BigInteger bigInteger = (System.Numerics.BigInteger)value;
                    if (!Math.Abs(schema.DivisibleBy.Value - Math.Truncate(schema.DivisibleBy.Value)).Equals(0.0))
                    {
                        flag = (bigInteger != 0L);
                    }
                    else
                    {
                        flag = (bigInteger % new System.Numerics.BigInteger(schema.DivisibleBy.Value) != 0L);
                    }
                }
                else
                {
                    flag = !JsonValidatingReader.IsZero((double)Convert.ToInt64(value, CultureInfo.InvariantCulture) % schema.DivisibleBy.GetValueOrDefault());
                }
                if (flag)
                {
                    this.RaiseError("Integer {0} is not evenly divisible by {1}.".FormatWith(CultureInfo.InvariantCulture, JsonConvert.ToString(value), schema.DivisibleBy), schema);
                }
            }
        }
 public void Init(int messageID, int currVal, int deltaVal, System.Numerics.BigInteger bigIntCurrVal, System.Numerics.BigInteger bigIntDeltaVal)
 {
     this.messageID      = messageID;
     this.currVal        = currVal;
     this.deltaVal       = deltaVal;
     this.bigIntCurrVal  = bigIntCurrVal;
     this.bigIntDeltaVal = bigIntDeltaVal;
 }
Exemple #49
0
 public ObjectDemoData(Int64 iValue)
 {
     this.iInt64   = iValue;
     this.iDouble  = iValue;
     this.iComplex = new Complex((double)iValue, 0);
     this.iBigInt  = iValue;
     this.iString  = iValue.ToString() + ":";
 }
        public void FeeIsSignatureContract_TestScope_CurrentHash_NEO_FAULT()
        {
            var wallet   = TestUtils.GenerateTestWallet();
            var snapshot = store.GetSnapshot();

            // no password on this wallet
            using (var unlock = wallet.Unlock(""))
            {
                var acc = wallet.CreateAccount();

                // Fake balance

                var key = NativeContract.GAS.CreateStorageKey(20, acc.ScriptHash);

                var entry = snapshot.Storages.GetAndChange(key, () => new StorageItem
                {
                    Value = new Nep5AccountState().ToByteArray()
                });

                entry.Value = new Nep5AccountState()
                {
                    Balance = 10000 * NativeContract.GAS.Factor
                }
                .ToByteArray();

                // Make transaction
                // Manually creating script

                byte[] script;
                using (ScriptBuilder sb = new ScriptBuilder())
                {
                    // self-transfer of 1e-8 GAS
                    System.Numerics.BigInteger value = (new BigDecimal(1, 8)).Value;
                    sb.EmitAppCall(NativeContract.GAS.Hash, "transfer", acc.ScriptHash, acc.ScriptHash, value);
                    sb.Emit(OpCode.THROWIFNOT);
                    script = sb.ToArray();
                }

                // trying global scope
                var cosigners = new Cosigner[] { new Cosigner
                                                 {
                                                     Account          = acc.ScriptHash,
                                                     Scopes           = WitnessScope.CustomContracts,
                                                     AllowedContracts = new[] { NativeContract.NEO.Hash }
                                                 } };

                // using this...

                // expects FAULT on execution of 'transfer' Application script
                // due to lack of a valid witness validation
                Transaction tx = null;
                Assert.ThrowsException <InvalidOperationException>(() =>
                                                                   tx = wallet.MakeTransaction(script, acc.ScriptHash, new TransactionAttribute[0], cosigners));
                Assert.IsNull(tx);
            }
        }
Exemple #51
0
        /// <summary>
        /// Mathematical modulus operator between this XSInteger and the supplied
        /// ResultSequence.
        /// </summary>
        /// <param name="arg">
        ///            The ResultSequence to perform a modulus with </param>
        /// <returns> A XSInteger consisting of the result of the mathematical modulus. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.eclipse.wst.xml.xpath2.api.ResultSequence mod(org.eclipse.wst.xml.xpath2.api.ResultSequence arg) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public override ResultSequence mod(ResultSequence arg)
        {
            ResultSequence carg = convertResultSequence(arg);

            XSInteger val = (XSInteger)get_single_type(carg, typeof(XSInteger));

            System.Numerics.BigInteger result = ((long)int_value()) % (val.int_value());

            return(ResultSequenceFactory.create_new(new XSInteger(result)));
        }
Exemple #52
0
 // Token: 0x06000D43 RID: 3395 RVA: 0x00053C54 File Offset: 0x00051E54
 public override void WriteValue(object value)
 {
     if (value is System.Numerics.BigInteger)
     {
         System.Numerics.BigInteger bigInteger = (System.Numerics.BigInteger)value;
         base.InternalWriteValue(JsonToken.Integer);
         this.WriteValueInternal(bigInteger.ToString(CultureInfo.InvariantCulture), JsonToken.String);
         return;
     }
     base.WriteValue(value);
 }
        private static uint256 ToUInt256(this System.Numerics.BigInteger input)
        {
            if (input.Sign < 1)
            {
                throw new ArgumentException(nameof(input), "input should not be negative");
            }

            var arr = input.ToByteArray();
            int len = arr.Length;

            if (arr[^ 1] == 0)
Exemple #54
0
 private static System.Numerics.BigInteger gcd(System.Numerics.BigInteger a, System.Numerics.BigInteger b)
 {
     if (b == 0)
     {
         return(a);
     }
     else
     {
         return(gcd(b, a % b));
     }
 }
Exemple #55
0
 // Token: 0x06001950 RID: 6480 RVA: 0x0007806C File Offset: 0x0007626C
 public override void WriteValue(object value)
 {
     if (value is System.Numerics.BigInteger)
     {
         System.Numerics.BigInteger bigInteger = (System.Numerics.BigInteger)value;
         base.SetWriteState(JsonToken.Integer, null);
         this.AddToken(new BsonBinary(bigInteger.ToByteArray(), BsonBinaryType.Binary));
         return;
     }
     base.WriteValue(value);
 }
Exemple #56
0
        /// <summary>
        /// Factorial
        /// </summary>
        /// <param name="Number"></param>
        /// <returns></returns>
        private static BigInteger Factorial(System.Numerics.BigInteger Number)
        {
            BigInteger Result = 1;

            while (Number >= 1)
            {
                Result = Result * Number;
                Number--;
            }

            return(Result);
        }
Exemple #57
0
        // Token: 0x06000A99 RID: 2713 RVA: 0x0003F5E4 File Offset: 0x0003D7E4
        public virtual int?ReadAsInt32()
        {
            JsonToken contentToken = this.GetContentToken();

            if (contentToken != JsonToken.None)
            {
                switch (contentToken)
                {
                case JsonToken.Integer:
                case JsonToken.Float:
                {
                    object value = this.Value;
                    int    num;
                    if (value is int)
                    {
                        num = (int)value;
                        return(new int?(num));
                    }
                    if (value is System.Numerics.BigInteger)
                    {
                        System.Numerics.BigInteger value2 = (System.Numerics.BigInteger)value;
                        num = (int)value2;
                    }
                    else
                    {
                        try
                        {
                            num = Convert.ToInt32(value, CultureInfo.InvariantCulture);
                        }
                        catch (Exception ex)
                        {
                            throw JsonReaderException.Create(this, "Could not convert to integer: {0}.".FormatWith(CultureInfo.InvariantCulture, value), ex);
                        }
                    }
                    this.SetToken(JsonToken.Integer, num, false);
                    return(new int?(num));
                }

                case JsonToken.String:
                {
                    string s = (string)this.Value;
                    return(this.ReadInt32String(s));
                }

                case JsonToken.Null:
                case JsonToken.EndArray:
                    goto IL_3A;
                }
                throw JsonReaderException.Create(this, "Error reading integer. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken));
            }
IL_3A:
            return(null);
        }
Exemple #58
0
 private sysnum.BigInteger hash(string source)
 {
     if (source == null || source.Length == 0)
     {
         return(sysnum.BigInteger.Zero);
     }
     else
     {
         char[] sourceArray     = source.ToCharArray();
         long   longsourceArray = (long)sourceArray[0];
         //if (longsourceArray < 8)
         //{
         //    longsourceArray <<= 12;
         //}
         //if (longsourceArray < 16)
         //{
         //    longsourceArray <<= 11;
         //}
         //if (longsourceArray < 32)
         //{
         //    longsourceArray <<= 10;
         //}
         //else if (longsourceArray < 64)
         //{
         //    longsourceArray <<= 9;
         //}
         //else if (longsourceArray < 128)
         //{
         //    longsourceArray <<= 8;
         //}
         if (longsourceArray < 1024)
         {
             longsourceArray *= 10;
             longsourceArray += 19200;
         }
         sysnum.BigInteger x = new sysnum.BigInteger(longsourceArray << 7);
         //sysnum.BigInteger x = new sysnum.BigInteger(((long)sourceArray[0]) << 7);
         sysnum.BigInteger m    = sysnum.BigInteger.Parse("1000003");
         sysnum.BigInteger mask = sysnum.BigInteger.Pow(new sysnum.BigInteger(2), this.hashbits) - sysnum.BigInteger.One;
         foreach (char item in sourceArray)
         {
             sysnum.BigInteger temp = new sysnum.BigInteger((long)item);
             x = ((x * m) ^ temp) & mask;
         }
         x = x ^ (new sysnum.BigInteger(source.Length));
         if (x.Equals(sysnum.BigInteger.MinusOne))
         {
             x = new sysnum.BigInteger(-2);
         }
         return(x);
     }
 }
Exemple #59
0
        static System.Numerics.BigInteger hash_to_curvebn(params UmbralPublicKey[] keys)
        {
            IEnumerable <byte> bytes = keys[0].ToBytes();

            for (var i = 1; i < keys.Length; i++)
            {
                bytes = bytes.Concat(keys[i].ToBytes());
            }
            var hash = ThinNeo.Helper.CalcSha256(bytes.ToArray());
            var h    = new System.Numerics.BigInteger(hash.Concat(new byte[] { 0 }).ToArray());

            return(h);
        }
 void SetPoint(
     [Inject] Config config,
     [Inject] TargetSender sender,
     [Parameter("设置的对象")] string target, //TODO 使用@ 和regex replace
     [Parameter("目标分数")] Number point)
 {
     if (!config.PlayerConfigs.ContainsKey(target))
     {
         sender.Send("玩家不存在,已经新建配置文件.");
     }
     config.GetPlayerConfig(target).Point = point;
     sender.Send("设置完成.");
 }