Base64, Hex
You can easily encode and decode data to and from Base64 and Hex:
1
say Base64("Winter is coming 🥶").encode() // V2ludGVyIGlzIGNvbWluZyDwn6W2
2
say Base64("V2ludGVyIGlzIGNvbWluZyDwn6W2").decode() // Winter is coming 🥶
3
4
say Hex("Winter is coming 🥶").encode() // 57696e74657220697320636f6d696e6720f09fa5b6
5
say Hex("57696e74657220697320636f6d696e6720f09fa5b6").decode() // Winter is coming 🥶
Copied!
This can for example be useful when using Basic Auth in HTTP calls:
1
do auth = Base64("user:password").encode()
2
3
do HTTP("https://example.com")
4
.set({ "Authorization": "Basic {{auth}}" })
5
.send()
Copied!
But in general, they are useful methods to encode/decode non-URL-safe or non-ASCII data to ensure exchanges between systems run smoothly.
Base64 and Hex are NOT encryption methods!
Last modified 6mo ago
Export as PDF
Copy link