for more information visit the package's GitHub page
Package contains the following modules:
This package helps you work with Base64 encoding, providing a similar interface as in elm/bytes and elm/json
THIS PACKAGE HAS BEEN RENAMED. PREVIOUS NAME was ivadzy/bbase64
Please update your dependencies, pay attention to the package version because it was reset to 1.0.1 from 1.1.1.
The package lets you create encoders and decoders to work with strings and bytes.
Converting a string into a Base64 string:
import Bytes.Encode
import Base64.Encode as Encode
input =
"Example input string"
encoded =
Encode.encode (Encode.string input)
Encoding a bytes seqeunce:
import Bytes.Encode
import Base64.Decode as Decode
import Base64.Encode as Encode
stringAsBytes =
Bytes.Encode.encode (Bytes.Encode.string "H💩la!")
encoded =
Encode.encode (Encode.bytes stringAsBytes)
decoded =
Decode.decode Decode.string encoded
Or you can decode string into raw bytes with Base64.Decode.bytes
:
import Base64.Decode as Decode
import Bytes
import Bytes.Decode
-- decodedAsBytes = Decode.decode Decode.bytes someInput
decodedAsString =
Bytes.Decode.decode (Bytes.Decode.string (Bytes.width decodedAsBytes)) decodedAsBytes
Also you can map Decoder
:
import Base64.Decode as Decode
input =
"TWFu"
decoder =
Decode.map String.reverse Decode.string
decoded =
Decode.decode decoder input -- naM