Skip to content
This repository has been archived by the owner on Dec 11, 2018. It is now read-only.

Latest commit

 

History

History
52 lines (43 loc) · 1.76 KB

README.md

File metadata and controls

52 lines (43 loc) · 1.76 KB

elm-crypto

Web Cryptography API for Elm.

It wraps RandomSource.getRandomValues API to generator cryptographically secure pseudorandom number in Elm.

Usage

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
Build Status
References


elm-crypto is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0). See COPYRIGHT for details.