UnicodeSmuggler (UnicodeSmuggler v0.1.0)
View SourceUnicodeSmuggler
Because it seemed like a good idea at the time, this is a quick implementation of the ideas in Paul Butler's blog post Smuggling arbitrary data through an emoji as a small Elixir package.
UnicodeSmuggler is a simple stenography utility that will hide text by attaching it to any Unicode character as a list of invisible "variation selectors". The character will render as normal in most unicode-compatible applications. UnicodeSmuggler (or anything else compatible with Paul Butler's code) can later be used to extract the hidden text.
As Paul makes clear this is, at best, an underhand hack and misuse of the Unicode standard. On the other hand, it's an interesting trick, I thought it would be fun to implement, and this library may possibly be of use for detecting such tricks in the wild.
Features
- Encode text in a Unicode character
- Decode text hidden in a Unicode character
- Find hidden text in a string
- Remove hidden text from a Unicode character
- Accidentally confuse JetBrains' IDEs like RubyMine and cause mysterious problems in your own tests
- Ducks
Examples
Encoding
UnicodeSmuggler.encode!("Aw yiss!")
# => "đŠó ±ó
§ó ó
©ó
ó
Łó
Ł"
Decoding
UnicodeSmuggler.decode!("đŠó ±ó
§ó ó
©ó
ó
Łó
Ł")
# => "Aw yiss!"
Trimming
UnicodeSmuggler.trim("đŠó ±ó
§ó ó
©ó
ó
Łó
Ł")
|> UnicodeSmuggler.decode!()
# => nil
Summary
Functions
Decodes and returns the hidden text in the specified container character.
Hides the text passed as the first parameter in the container character passed as the second parameter.
Scans a string for hidden text and returns any found fragments in a list.
Returns true if hidden text is found in the passed string, otherwise false.
Accepts a single character and returns it without hidden text. Hopefully.
Functions
Decodes and returns the hidden text in the specified container character.
A nil value will be returned if no text has been hidden.
Hides the text passed as the first parameter in the container character passed as the second parameter.
If no container character is specified then a duck will be returned.
Scans a string for hidden text and returns any found fragments in a list.
If no hidden text is found an empty list will be returned.
Returns true if hidden text is found in the passed string, otherwise false.
Accepts a single character and returns it without hidden text. Hopefully.