[BUG] convert a Hex string to byte array to Base 64. #6490
Replies: 3 comments
-
Closing, not a bug. |
Beta Was this translation helpful? Give feedback.
-
@pacmano1 Paul. Mirth is not able to convert to base64 using com.mirth.connect.server.userutil.FileUtil.encode(). It is giving the below error: Cannot convert org.mozilla.javascript.NativeArray@6b1ba8a1 to byte[] E.g I need to convert aef560e5-7be4-461b-b92a-758eb5cf3c1f (hex string) to URL safe (RFC 4686) Base 64 encoded value. I am ble to cinver tgis hex strting to a byte[] but then when I trying to base64 encode, its giving below error: Cannot convert org.mozilla.javascript.NativeArray@6b1ba8a1 to byte[] |
Beta Was this translation helpful? Give feedback.
-
Is this what you are asking? var uuid = "aef560e5-7be4-461b-b92a-758eb5cf3c1f";
// Convert to bytes (UTF-8 here; for raw hex you'd parse differently)
var bytes = new java.lang.String(uuid).getBytes("UTF-8");
// Encode to Base64
var b64 = Packages.org.apache.commons.codec.binary.Base64.encodeBase64String(bytes);
// Make URL-safe
var b64url = ("" + b64)
.replace(/\+/g, "-")
.replace(/\//g, "_")
.replace(/=+$/, "");
logger.info(b64url);
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I need to convert a Hex string to byte array to Base 64. But MIrth is giving error not able conver native Mozilla Java Scriot to Java type to be used by FileUtil. Any insights or approach or soultion I can use? Thanks
Beta Was this translation helpful? Give feedback.
All reactions