Web Cryptography API for Elm.
It wraps RandomSource.getRandomValues
API to generator cryptographically
secure pseudorandom number in Elm.
Random generation function return a Task
. Depending on your use case, you
might want to convert the task to an Cmd
or otherwise use it.
update : Msg -> Model -> (Model, Cmd Msg)
update action model =
case action of
Toss ->
let
resultToCmd : Result Crypto.Error Bool -> Msg
resultToCmd result = case result of
Ok boolean -> Catch boolean
Err error -> Failed error
cmd = Task.attempt resultToCmd Crypto.bool
in (model, cmd)
Catch coin -> ({ model | coin = Just coin }, Cmd.none)
Build Status |
---|
- Web Cryptography API - W3C Editor’s Draft 24 October 2016
- Cryptographically secure random numbers in Elm - Sergey Yavnyi
elm-crypto is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0). See COPYRIGHT for details.