Created
October 30, 2014 19:44
-
-
Save GantMan/30ef8ac19ca6b4249d7a to your computer and use it in GitHub Desktop.
RubyMotion 64bit encode/decode
This file contains 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
# ~~ 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