patricksrobertson / secure_random.ex Goto Github PK
View Code? Open in Web Editor NEWConvenience library for random base64 strings modeled after my love for Ruby's SecureRandom
License: Apache License 2.0
Convenience library for random base64 strings modeled after my love for Ruby's SecureRandom
License: Apache License 2.0
I noticed that the UUID being generated isn't following the UUID v4 schema.
This algorithm sets the version number (4 bits) as well as two reserved bits. All other bits (the remaining 122 bits) are set using a random or pseudorandom data source. Version 4 UUIDs have the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and y is one of 8, 9, A, or B (e.g., f47ac10b-58cc-4372-a567-0e02b2c3d479).
For a conformant UUID v4 implementation, see the generate function in https://github.com/elixir-lang/ecto/blob/master/lib/ecto/uuid.ex
When I execute SecureRandom.hex(12) multiple times, it returns quite often Strings with a length of 23 characters instead of 24 characters. I think this is not the expected behavior, as the Ruby counterpart returns strings with a constant size of the expected 24 characters.
iex(1)> SecureRandom.hex(12) |> String.length
24
iex(2)> SecureRandom.hex(12) |> String.length
24
iex(3)> SecureRandom.hex(12) |> String.length
24
iex(4)> SecureRandom.hex(12) |> String.length
23
iex(5)> SecureRandom.hex(12) |> String.length
24
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.