예제 #1
0
        public async Task <ActionResult <string> > Post(AK ak)
        {
            BigInteger a;
            uint       k;

            try
            {
                if (ak.a == null || ak.k == null)
                {
                    throw new FormatException();
                }
                a = BitOperation.BinStrToBigInteger(ak.a);
                k = Convert.ToUInt32(ak.k, 10);

                if (k > 31 || ak.a.Length > 32)
                {
                    throw new FormatException();
                }
            }
            catch (FormatException)
            {
                ModelState.AddModelError("Error", "Некорректные параметры");
                return(BadRequest(ModelState));
            }

            return(await Task.Run(() => BitOperation.BigIntegerToBinStr(BitOperation.ChangeBit(a, k))));
        }