Пример #1
0
        public string Generate()
        {
            var      peselStringBuilder = new StringBuilder();
            DateTime birthDate          = GenerateDate(1900, 2099);

            AppendPeselDate(birthDate, peselStringBuilder);

            peselStringBuilder.Append(GenerateRandomNumbers(4));

            peselStringBuilder.Append(PeselCheckSumCalculator.Calculate(peselStringBuilder.ToString()));

            return(peselStringBuilder.ToString());
        }
Пример #2
0
        public static bool IsValid(string pesel)
        {
            var regex = new Regex("^\\d{11}$");

            if (!regex.IsMatch(pesel))
            {
                return(false);
            }

            int checkSum  = PeselCheckSumCalculator.Calculate(pesel);
            int lastDigit = pesel.Last() - '0';

            return(lastDigit == checkSum);
        }