Esempio n. 1
0
        public void TestLuhn()
        {
            var accountNumber     = "000001";
            var accNumberWithLuhn = ClsLuhnLibrary.WithLuhn_Base10(accountNumber);

            Assert.That(accNumberWithLuhn.EndsWith("8"));

            var isValid = ClsLuhnLibrary.CheckLuhn_Base10(accNumberWithLuhn);

            Assert.That(isValid);
        }
Esempio n. 2
0
        public async Task <string> GetNextValue(NumberRangeType rangeType)
        {
            var nextValue = await GetLastValue(rangeType) + 1;

            while (await Exists(nextValue, rangeType))
            {
                nextValue = await GetLastValue(rangeType) + 1;
            }

            var numberRange = await GetNumberRange(rangeType);

            numberRange.LastValue = nextValue;
            await _db.SaveChangesAsync();

            var paddedNextVal   = nextValue.ToString($"D{numberRange.RangeEnd.ToString().Length}");
            var nextValWithLuhn = ClsLuhnLibrary.WithLuhn_Base10(paddedNextVal);

            return(nextValWithLuhn);
        }
 public byte[] GenerateLuhnCodeSlxLuhnLibrary() => Encoding.ASCII.GetBytes(ClsLuhnLibrary.WithLuhn_Base10(Encoding.ASCII.GetString(CardCode)));