Skip to content

A .NET library to create and verify values using the Luhn algorithm. F# and C# friendly.

License

Notifications You must be signed in to change notification settings

gtbuchanan/Luhny

Repository files navigation

Luhny

CI

A .NET Library to create and verify values using the Luhn algorithm. F# and C# friendly.

Usage

Import

// F#
open Luhny.FSharp
// C#
using Luhny;

Create String

// F#
let luhnString =
  match LuhnLength.create 16 with
  | Ok length -> Luhn.create length None
  | _ -> failwith "Invalid Length"
// C#
var luhnString = Luhn.Create(16);

Create String w/Prefix

// F#
let luhnString =
  match LuhnLength.create 15 with
  | Ok length -> Luhn.create length (Some "34")
  | _ -> failwith "Invalid Length"
// C#
var luhnString = Luhn.Create(15, "34");

Create Int64

// F#
let luhnNumber =
  match LuhnInt64Length.create 16 with
  | Ok length -> Luhn.createInt64 length None
  | _ -> failwith "Invalid Length"
// C#
var luhnNumber = Luhn.CreateInt64(16);

Create Int64 w/ Prefix

// F#
let luhnNumber =
  match LuhnInt64Length.create 15 with
  | Ok length -> Luhn.createInt64 length (Some 34L)
  | _ -> failwith "Invalid Length"
// C#
var luhnNumber = Luhn.CreateInt64(15, 34L);

Verify String

// F#
let isValid = Luhn.verify "378282246310005"
// C#
var isValid = Luhn.Verify("378282246310005");

Verify Int64

// F#
let isValid = Luhn.verifyInt64 378282246310005L
// C#
var isValid = Luhn.Verify(378282246310005L);

About

A .NET library to create and verify values using the Luhn algorithm. F# and C# friendly.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •