Created
December 2, 2020 06:07
-
-
Save timotheecour/cdfa0d379d795006cf035c9309b27951 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Encoding data | |
## ------------- | |
## | |
runnableExamples: | |
let encoded = encode("Hello World") | |
assert encoded == "SGVsbG8gV29ybGQ=" | |
## Apart from strings you can also encode lists of integers or characters: | |
runnableExamples: | |
let encodedInts = encode([1,2,3]) | |
assert encodedInts == "AQID" | |
let encodedChars = encode(['h','e','y']) | |
assert encodedChars == "aGV5" | |
## Decoding data | |
## ------------- | |
## | |
runnableExamples: | |
let decoded = decode("SGVsbG8gV29ybGQ=") | |
assert decoded == "Hello World" | |
## URL Safe Base64 | |
## --------------- | |
## | |
runnableExamples: | |
doAssert encode("c\xf7>", safe = true) == "Y_c-" | |
doAssert encode("c\xf7>", safe = false) == "Y/c+" | |
## See also | |
## ======== | |
## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment