Giter Site home page Giter Site logo

Comments (3)

dingosky avatar dingosky commented on September 23, 2024

For non-power of 2 length charsets look at https://github.com/puid/Elixir. That library is an extension of EntropyString to any custom character sets. An optimized version for the characters you listed is actually already provided.

Using the Puid library does, of course, require the caveats of calling Elixir code from Erlang. I used mix to create a quick Elixir project that had one file, upper_alpha_num.ex:

defmodule(UpperAlphaNum, do: use(Puid, bits: 96, charset: :alphanum_upper))

I ran an Erlang shell including the BEAM files from the compilation of that simple Elixir project, as well as the BEAM files for Elixir, and got:

1> 'Elixir.UpperAlphaNum':info().
#{'struct' => 'Elixir.Puid.Info',
chars => <<"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789">>,
charset => alphanum_upper,entropy_bits => 98.23,
entropy_bits_per_char => 5.17,ere => 0.65,length => 19,
rand_bytes => fun crypto:strong_rand_bytes/1}

2> 'Elixir.UpperAlphaNum':generate().
<<"BHG00YLBEKLBAANM1AK">>

from erlang.

yhafri avatar yhafri commented on September 23, 2024

Thanks for your help but i've zero interest on Elixir and for sure i'll not ship BEAM code that way.

from erlang.

dingosky avatar dingosky commented on September 23, 2024

Are the characters really important? You could drop four of them and have a 32 length set. Using 96-bits of entropy (you didn't specify), the difference is:

36 characters:
  entropy_bits: 98.23,
  entropy_bits_per_char: 5.17,
  ere: 0.65,
  length: 19
32 characters:
  entropy_bits: 100.0,
  entropy_bits_per_char: 5.0,
  ere: 0.63,
  length: 20

from erlang.

Related Issues (1)

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.