All Projects → ssg → Turkishid

ssg / Turkishid

Licence: apache-2.0
Validator/generator for Turkish Republic Citizen ID numbers (TC Kimlik No)

Projects that are alternatives of or similar to Turkishid

M2x Python
AT&T M2X Python Library
Stars: ✭ 25 (-48.98%)
Mutual labels:  libraries
Ghpr.nunit
Adapter for NUnit 3 (generate HTML report for NUnit 3)
Stars: ✭ 33 (-32.65%)
Mutual labels:  nuget
Django Icekit
GLAMkit is a next-generation Python CMS by the Interaction Consortium, designed especially for the cultural sector.
Stars: ✭ 42 (-14.29%)
Mutual labels:  libraries
Myanimelistsharp
Access MyAnimeList Web API using .NET library
Stars: ✭ 10 (-79.59%)
Mutual labels:  nuget
Blazm.components
A few useful and awesome components for Blazor. Blazor + awesome (azm)=Blazm (Blossom)
Stars: ✭ 29 (-40.82%)
Mutual labels:  nuget
Msbuildstructuredlog
A logger for MSBuild that records a structured representation of executed targets, tasks, property and item values.
Stars: ✭ 988 (+1916.33%)
Mutual labels:  nuget
Centrifuge
Cross-platform runtime mod loader and API for any Unity-based game. Supports Unity 5 and up!
Stars: ✭ 18 (-63.27%)
Mutual labels:  nuget
Inqlude Data
Library meta data for independent Qt library archive
Stars: ✭ 44 (-10.2%)
Mutual labels:  libraries
Bit
Bitcoin made easy.
Stars: ✭ 958 (+1855.1%)
Mutual labels:  libraries
Teamcity Nuget Support
TeamCity NuGet support
Stars: ✭ 40 (-18.37%)
Mutual labels:  nuget
Awesome ai for libraries
A list of awesome artificial intelligence resources for the GLAM community.
Stars: ✭ 12 (-75.51%)
Mutual labels:  libraries
Appdepends Ios
🔍 搜集热门APP,列举其所依赖和使用的开源库。
Stars: ✭ 27 (-44.9%)
Mutual labels:  libraries
Simplenetnlp
.NET NLP library
Stars: ✭ 38 (-22.45%)
Mutual labels:  nuget
Weixinmpsdk
微信全平台 SDK Senparc.Weixin for C#,支持 .NET Framework 及 .NET Core、.NET 6.0。已支持微信公众号、小程序、小游戏、企业号、企业微信、开放平台、微信支付、JSSDK、微信周边等全平台。 WeChat SDK for C#.
Stars: ✭ 7,098 (+14385.71%)
Mutual labels:  nuget
Fluenttc
🌊 👬 🏢 Integrate with TeamCity fluently
Stars: ✭ 42 (-14.29%)
Mutual labels:  nuget
Apos.input
Polling input library for MonoGame.
Stars: ✭ 25 (-48.98%)
Mutual labels:  nuget
Computesharp
A .NET 5 library to run C# code in parallel on the GPU through DX12 and dynamically generated HLSL compute shaders, with the goal of making GPU computing easy to use for all .NET developers! 🚀
Stars: ✭ 982 (+1904.08%)
Mutual labels:  nuget
Vs Validation
Common input and integrity validation routines for Visual Studio and other applications
Stars: ✭ 48 (-2.04%)
Mutual labels:  nuget
Formatwith
String extensions for named parameterized string formatting.
Stars: ✭ 44 (-10.2%)
Mutual labels:  nuget
Rxdownloader
- Reactive Extension Library for Android to download files
Stars: ✭ 40 (-18.37%)
Mutual labels:  libraries

NuGet Version Build Status

TurkishId

Validator (and a random generator tool) for Turkish Republic's citizen ID numbers. I've decided to give this a shot last night while I was waiting for a download. And Turkish ID numbers were really popular in Turkish social media last week. The Id number is called "T.C. Kimlik No" (Turkish Republic Identity Number). I decided to use English translation to allow easier handling in international projects.

Usage

I wanted the TurkishIdNumber representation to be used anywhere in the code as a value to pass around when using id's allowing to assume an instance is already validated saving you from redundant checks.

When you want to use it as a representation of an ID number:

using TurkishId;
var id = new TurkishIdNumber("12345678901");
// throws ArgumentException when invalid parameter is passed

or if you just want to validate it:

using TurkishId;
bool reallyValid = TurkishIdNumber.IsValid("12345678901");

NuGet package is here: https://www.nuget.org/packages/TurkishId/

TurkishId.ModelBinder

There is also a model binder package that you can install at https://www.nuget.org/packages/TurkishId.ModelBinder. It's a plug'n'play model binder which lets you to use TurkishIdNumber class directly in your model declarations.

It's not part of the original package because you may not want to have whole MVC as a dependency.

To set it up in an ASP.NET Core project, use this syntax in your ConfigureServices method in your Startup class:

services.AddMvc(options =>
{
  options.ModelBinderProviders.Insert(0, new TurkishIdModelBinderProvider());
});

and you're done. If you'd like to use it in your Razor Pages app use AddMvcOptions instead:

services.AddRazorPages()
  .AddMvcOptions(options => options.ModelBinderProviders.Insert(0, new TurkishIdModelBinderProvider()));

or, alternatively, if you only use controllers you can add it to your AddControllers options:

services.AddMvc(options =>
{
  options.ModelBinderProviders.Insert(0, new TurkishIdModelBinderProvider());
});

The model binder package will use ASP.NET Core's model binding message providers. You can now localize them like how you do any other model binder.

Performance

This is probably one of the fastest implementations on .NET. I didn't grind so much on performance but it can easily handle millions of validations per second on my Core i7.

Algorithm

Turkish Republic's ID structure and verification is simple. It's an eleven digit number. If we name each digit as d(n) where leftmost digit is called d1 and the rightmost d11, a given ID is valid if:

d1 > 0

and

n = (d1 + d3 + d5 + d7 + d9) * 7 - (d2 + d4 + d6 + d8)

if n < 0 then n = n + 10

d10 = n mod 10

and

d11 = sum(d1..d10) mod 10

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].