Skip to content

Instantly share code, notes, and snippets.

@juxtin
Created May 6, 2016 07:08
Show Gist options
  • Save juxtin/bc66d62f0959756d2ab522d3135e0f6f to your computer and use it in GitHub Desktop.
Save juxtin/bc66d62f0959756d2ab522d3135e0f6f to your computer and use it in GitHub Desktop.
b64map : [64][8]
b64map = ['A' .. 'Z'] # ['a' .. 'z'] # ['0' .. '9'] # ['/', '+']
toB64Char : [6] -> [8]
toB64Char x = b64map @ x
base64 xs = [ toB64Char x | x <- hexBytes ]
where hexBytes = groupBy`{6} xs
passes = actual == expected
where
input = 0x49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d
actual = base64 input
expected = "SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment