Пример #1
0
        private static bool HasValidNumbers(string valor)
        {
            var number         = valor.Substring(0, CpfSize - 2);
            var numberVerifier = new NumberVerifier(number)
                                 .WithMultipliers(2, 11)
                                 .Swap("0", 10, 11);
            var firstDigit = numberVerifier.CalculateNumber();

            numberVerifier.AddNumber(firstDigit);
            var secondDigit = numberVerifier.CalculateNumber();

            return(string.Concat(firstDigit, secondDigit) == valor.Substring(CpfSize - 2, 2));
        }
Пример #2
0
        private static bool HasValidNumbers(string value)
        {
            var number = value.Substring(0, CnpjSize - 2);

            var numberVerifier = new NumberVerifier(number)
                                 .WithMultipliers(2, 9)
                                 .Swap("0", 10, 11);
            var firstNumber = numberVerifier.CalculateNumber();

            numberVerifier.AddNumber(firstNumber);
            var secondNumber = numberVerifier.CalculateNumber();

            return(string.Concat(firstNumber, secondNumber) == value.Substring(CnpjSize - 2, 2));
        }