Created
September 26, 2017 21:16
-
-
Save icodealot/0f24f4e322c15d2c8558751cba1ea0d5 to your computer and use it in GitHub Desktop.
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
// This is a minimal Base64 encode/decode utility for Nashorn -> JavaScript | |
// Add error checking for data types as needed within encode or decode | |
var Base64 = { | |
decode: function (str) { | |
return new java.lang.String(java.util.Base64.decoder.decode(str)); | |
}, | |
encode: function (str) { | |
return java.util.Base64.encoder.encodeToString(str.bytes); | |
} | |
}; | |
print(Base64.decode(Base64.encode("Hello, World!"))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment