Coder Social home page Coder Social logo

cuid2's Introduction

prosser/Cuid2

C# implementation of the paralleldrive/cuid2 NPM package.

Makes use of a local implementation of OnixLabs.Security.Cryptography.Sha3 to permit use on pre-net7.0 systems.

To generate a new CUID2 id:

string id = Cuid2.CreateId();

To generate a CUID2 id of a different length (2 - 32 characters are valid):

string id = Cuid2.CreateId(10);

To customize the generation:

// The Cuid2.Init method returns a custom CreateId function with the specified
// configuration. All configuration properties are optional.
Func<string> createId = Cuid2.Init(
  // An implementation of System.Security.Cryptography.RandomNumberGenerator
  random: RandomNumberGenerator.Create(),
  // the length of the id
  length: 10,
  // A custom fingerprint for the host environment. This is used to help
  // prevent collisions when generating ids in a distributed system.
  fingerprint: "a-custom-host-fingerprint");

int count = 3;
while (count-- > 0)
{
    Console.WriteLine(createId());
}

cuid2's People

Contributors

prosser avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.