Created
June 17, 2015 00:55
-
-
Save gfredericks/af951e56680127f10eb8 to your computer and use it in GitHub Desktop.
Encoding strings as a collection of NaNs.
This file contains hidden or 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
(ns sneaky-NaNs | |
"Secret codez.") | |
(defn char->NaN | |
[c] | |
(-> c | |
(int) | |
(bit-or 0x7ff8000000000000) | |
(Double/longBitsToDouble))) | |
(defn NaN->char | |
[nan] | |
(-> nan | |
(Double/doubleToRawLongBits) | |
(bit-and 0xffffffffffff) | |
(char))) | |
(->> "¡Hello, world! ☺" (map char->NaN)) | |
=> (NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN) | |
(->> "¡Hello, world! ☺" (map char->NaN) (map NaN->char) (apply str)) | |
=> "¡Hello, world! ☺" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
stenanography.com is still available! :-)