Skip to content

Instantly share code, notes, and snippets.

@GantMan
Created October 30, 2014 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GantMan/30ef8ac19ca6b4249d7a to your computer and use it in GitHub Desktop.
Save GantMan/30ef8ac19ca6b4249d7a to your computer and use it in GitHub Desktop.
RubyMotion 64bit encode/decode
# ~~ ENCODING TO Base64 ~~ #
start = "This is a test".dataUsingEncoding(NSUTF8StringEncoding)
#=> This is a test
encoded = start.base64EncodedStringWithOptions(0)
#=> "VGhpcyBpcyBhIHRlc3Q="
# ~~ DECODING FROM Base64 ~~ #
decoded = NSData.alloc.initWithBase64EncodedString(encoded, options: 0)
#=> This is a test
stringy = NSString.alloc.initWithData(decoded, encoding: NSUTF8StringEncoding)
#=> "This is a test"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment