I am trying to to do a base64 encode of byte array. However, I am limited for choices. btoa() method is not supported by Rhino Javascript engine. Is there a way this can be achieved.
Below snippet error that rhino js does not support.
java.util.concurrent.ExecutionException: javax.script.ScriptException: ReferenceError: "btoa" is not defined.
Below is snippet of code.
var encodedData = btoa(stringToEncode);
I am trying to encode salted sha256 byte array into base64.
var md = java.security.MessageDigest.getInstance('SHA-256');
md.update(salt);
var sha256Bytes = []
sha256Bytes=md.digest(new java.lang.String(givenPassword).getBytes('UTF-8'))
var sha256Hash = btoa(sha256Bytes);