Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/patricksrobertson/secure_random.ex
Convenience library for random base64 strings modeled after my love for Ruby's SecureRandom
https://github.com/patricksrobertson/secure_random.ex
Last synced: 7 days ago
JSON representation
Convenience library for random base64 strings modeled after my love for Ruby's SecureRandom
- Host: GitHub
- URL: https://github.com/patricksrobertson/secure_random.ex
- Owner: patricksrobertson
- License: apache-2.0
- Created: 2015-01-22T13:21:08.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2023-03-23T23:56:49.000Z (over 1 year ago)
- Last Synced: 2024-05-02T11:12:26.863Z (6 months ago)
- Language: Elixir
- Size: 130 KB
- Stars: 96
- Watchers: 2
- Forks: 18
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - Convenience library for random base64 strings modeled after my love for Ruby's SecureRandom. (Text and Numbers)
- fucking-awesome-elixir - secure_random - Convenience library for random base64 strings modeled after my love for Ruby's SecureRandom. (Text and Numbers)
- awesome-elixir - secure_random - Convenience library for random base64 strings modeled after my love for Ruby's SecureRandom. (Text and Numbers)
README
# SecureRandom.ex [![[travis]](https://travis-ci.org/patricksrobertson/secure_random.ex.png)](https://travis-ci.org/patricksrobertson/secure_random.ex)
SecureRandom is an elixir module loosely based on Ruby's SecureRandom.
I needed urlsafe, random, base64 strings and UUID generation, so I ported over
what I needed :).This gets its random from Erlang's `strong_rand_bytes/1` and is strongly based
from this [gist](https://gist.github.com/Myuzu/7367461). I had to remove some
things that didn't make it to Elixir 1.0, and cut the stuff that I do not
currently have use for.Will accept PR's to flesh out further.
# INSTALL
Add this to your mix.exs:
```elixir
defp deps do
[{:secure_random, "~> 0.5"}]
end
```Fetch this motherlover:
```sh
mix deps.get
```# USAGE
UUID:
```elixir
SecureRandom.uuid # => "e8bc6fde-3c11-cc2e-903b-745221154d8a"
```base64 string:
```elixir
SecureRandom.base64(8) # => "VsifwaD2HCk="
```urlsafe_base64 string:
```elixir
SecureRandom.urlsafe_base64 #=> "WAut546EWdXM3O_9sJGvmQ"
```# AUTHOR
Brought to you by [Adequate Kitchen](http://adequate.io) which is a vague way
saying Patrick Robertson.# LICENSE
Apache 2.0