A .NET version of Ivan Akimov's NodeJS hashids library.
C#
Latest commit 745ec6e Jul 18, 2014 @maxnachlinger maxnachlinger Merge pull request #3 from rodc2/master
Changed integer divide on hashids.cs:line 49 to floating divide

README.md

hashids.net

A .NET version of Ivan Akimov's NodeJS hashids library.

Build Status

Usage:

// all params are optional (though you really should use a salt)
var hashids = new Hashids(
  salt: "this is my salt", 
  alphabet: "abcdefghijklmnopqrstuvwxyz0123456789", 
  minHashLength: 0
);

// encrypting 
// a simple long
var encrypted = hashids.Encrypt(1234567890); // result: "y2jl7rm5"
// N longs
encrypted = hashids.Encrypt(1234567890,9876543210,654987321,456123789)); 
// OR
encrypted = hashids.Encrypt(new List<long>(){1234567890,9876543210,654987321,456123789})); 
// result: "jxypk9w2frmlyvk19cqjr8jmeapj34ry7"

// decrypting
var decryptedLong = hashids.DecryptOne("y2jl7rm5"); // result: 1234567890
var decryptedListOfLongs = hashids.Decrypt("jxypk9w2frmlyvk19cqjr8jmeapj34ry7"); 
// result: List<long>(){ 1234567890,9876543210,654987321,456123789 }

TODO:

The C# needs some refactoring to be, well, more like what a C# developer might expect :)

Contributors:

License

The MIT License

Copyright (c) 2013 Mindflash, Inc.