Exemple #1
0
        public static uint DecryptUInt(byte[] key, byte[] tweak, uint source, uint range = uint.MaxValue)
        {
            if (source >= uint.MaxValue)
            {
                throw new ArgumentException($"source should be less than {uint.MaxValue}");
            }

            if (source > range)
            {
                throw new ArgumentException($"source should be less than range");
            }

            BigInteger modulus  = new BigInteger(range);
            BigInteger sourceBI = new BigInteger(source);
            BigInteger result   = FE1.Decrypt(modulus, sourceBI, key, tweak);

            return((uint)result);
        }
Exemple #2
0
        public static ulong EncryptULong(byte[] key, byte[] tweak, ulong source, ulong range = ulong.MaxValue)
        {
            if (source >= ulong.MaxValue)
            {
                throw new ArgumentException($"source should be less than {uint.MaxValue}");
            }

            if (source > range)
            {
                throw new ArgumentException($"source should be less than range");
            }

            BigInteger modulus = new BigInteger(range);
            BigInteger plain   = new BigInteger(source);
            BigInteger result  = FE1.Encrypt(modulus, plain, key, tweak);

            return((ulong)result);
        }