Skip to content

MichaelCombs28/elm-nanoid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

elm-nanoid

Nano ID logo by Anton Lovchikov

This package is an Elm implementation of ai/nanoid.

Features of this nanoid package are:

Install

elm install MichaelCombs28/elm-nanoid

Example

import Nanoid
import Random

...

update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
  case msg of
    GenerateNanoid ->
      (model, Random.generate NanoidGenerated Nanoid.generator)

For more complete examples, see the examples folder.

Security

See comparison of Nano ID and UUID(V4):

"Nano ID is quite comparable to UUID v4 (random-based). It has a similar number of random bits in the ID (126 in Nano ID and 122 in UUID), so it has a similar collision probability -- for there to be a one in a billion chance of duplication, 103 trillion version 4 IDs must be generated"

With Elm, there are always randomness concerns which is the cost for reliability. Flags generated with a few bytes of randomness passed to a decent PCG library should cover most usecases.

More on PCG Here

About

A nanoid implementation for Elm

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages