A .NET Library to create and verify values using the Luhn algorithm. F# and C# friendly.
// F#
open Luhny.FSharp
// C#
using Luhny;
// F#
let luhnString =
match LuhnLength.create 16 with
| Ok length -> Luhn.create length None
| _ -> failwith "Invalid Length"
// C#
var luhnString = Luhn.Create(16);
// 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");
// F#
let luhnNumber =
match LuhnInt64Length.create 16 with
| Ok length -> Luhn.createInt64 length None
| _ -> failwith "Invalid Length"
// C#
var luhnNumber = Luhn.CreateInt64(16);
// 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);
// F#
let isValid = Luhn.verify "378282246310005"
// C#
var isValid = Luhn.Verify("378282246310005");
// F#
let isValid = Luhn.verifyInt64 378282246310005L
// C#
var isValid = Luhn.Verify(378282246310005L);