PESEL 2.1.4-rc.7

This is a prerelease version of PESEL.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package PESEL --version 2.1.4-rc.7
                    
NuGet\Install-Package PESEL -Version 2.1.4-rc.7
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PESEL" Version="2.1.4-rc.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PESEL" Version="2.1.4-rc.7" />
                    
Directory.Packages.props
<PackageReference Include="PESEL" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PESEL --version 2.1.4-rc.7
                    
#r "nuget: PESEL, 2.1.4-rc.7"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PESEL@2.1.4-rc.7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PESEL&version=2.1.4-rc.7&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=PESEL&version=2.1.4-rc.7&prerelease
                    
Install as a Cake Tool

PESEL (Universal Electronic System for Population Registration in Poland)

A .NET library for PESEL number validation.

NuGet


Documentation


Installation

The library is available on the NuGet Gallery.

Install-Package PESEL

PESEL Validation

A PESEL number can be validated using the PeselValidator class or the PeselAttribute, which can be applied to model properties.

Using PeselValidator

var validator = new PeselValidator();

var entity = new PeselEntity("02070803628");

var validationResult = validator.Validate(entity);

Assert.IsTrue(validationResult.IsValid);

The ValidationResult object also contains parsed information extracted from the PESEL number, such as gender and date of birth.


Algorithm References


Date of Birth Encoding

The date of birth is encoded numerically as:

YYMMDD

To distinguish between centuries, the following encoding rules are used:

  • 1900–1999 → month encoded normally (01–12)
  • 1800–1899 → month + 80
  • 2000–2099 → month + 20
  • 2100–2199 → month + 40
  • 2200–2299 → month + 60

Gender

Gender information is encoded in the 10th digit (the second-to-last digit) of the PESEL number:

  • 0, 2, 4, 6, 8 → female
  • 1, 3, 5, 7, 9 → male

After a legal gender change, a new PESEL number is issued.


Checksum Digit and Validation

The 11th digit is a checksum digit used to detect errors. It is calculated based on the first ten digits.

Let a–j represent consecutive digits of the PESEL number. The checksum is calculated as:

9×a + 7×b + 3×c + 1×d + 9×e + 7×f + 3×g + 1×h + 9×i + 7×j

If the last digit of the result does not match the checksum digit, the PESEL number is invalid.

Example

For the PESEL number 44051401358:

9×4 + 7×4 + 3×0 + 1×5 + 9×1 + 7×4 + 3×0 + 1×1 + 9×3 + 7×5 = 169
169 % 10 = 9

Since 9 ≠ 8, the PESEL number is invalid.


Equivalent Validation Method

An equivalent method uses the following weighted sum:

1×a + 3×b + 7×c + 9×d + 1×e + 3×f + 7×g + 9×h + 1×i + 3×j + 1×k

If the last digit of the result is 0, the PESEL number is valid. Otherwise, it is invalid.


Algorithm Limitations

The checksum algorithm has known limitations:

  • swapping year and day (yy-mm-dddd-mm-yy) may produce the same checksum
  • the algorithm does not validate semantic correctness of the data

Due to the checksum properties, a missing digit can sometimes be reconstructed.


Errors in PESEL Assignment

In practice, PESEL numbers with errors have existed, including:

  • incorrect birth dates
  • duplicated serial numbers
  • incorrect gender encoding
  • invalid checksum digits

Some of these issues were discovered years later during data migration. Therefore, a successful checksum validation does not guarantee that a PESEL number was officially assigned.

A PESEL number can be changed in cases such as:

  • legal gender change
  • issuance of a new birth certificate
  • administrative errors

In 2012, administrative mistakes resulted in the same PESEL number being assigned to different individuals in approximately 2,000 cases.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on PESEL:

Package Downloads
PESEL.System.ComponentModel.DataAnnotations

Atrybut walidacji numeru PESEL oparty o System.ComponentModel.DataAnnotations.

PESEL.FluentValidation

Rozszerzenie FluentValidation dla biblioteki PESEL.

PESEL.Generator

Biblioteka umożliwiająca generowanie numerów PESEL.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.4-rc.8 106 1/10/2026
2.1.4-rc.7 91 1/9/2026
2.1.4-rc.6 92 1/9/2026
2.1.4-rc.5 86 1/8/2026
2.1.4-rc.4 87 1/8/2026
2.1.4-rc.3 90 1/7/2026
2.1.4-rc.2 90 1/7/2026
2.1.4-rc.1 91 1/7/2026
2.1.3 27,619 1/7/2026
2.1.3-rc.2 84 1/7/2026
2.1.3-rc.1 94 1/7/2026
2.1.2 272 1/6/2026
2.1.2-rc.1 88 1/6/2026
2.1.1 174 1/6/2026
2.1.1-rc.2 91 1/6/2026
2.1.1-rc.1 94 1/6/2026
2.0.2-rc.9 91 1/4/2026
2.0.2-rc.8 92 1/4/2026
2.0.2-rc.7 94 1/4/2026
2.0.2-rc.6 87 1/4/2026
Loading failed