简体   繁体   中英

Decode Base64 string

I am currently working on a custom SAPUI5 app. I would like to make a service call, which expects the Guid in a different format than it is currently available.

An example:

  • Available (base64): QvLAUUzUCZbhAAAAjSS2iA==
  • As it should be (hexadecimal): 42F2C0514CD40996E10000008D24B688

I have not found an online decoder, which could produce the desired result, however, I was able to encode the guid 42F2C0514CD40996E10000008D24B to QvLAUUzUCZbhAAAAjss2iA== with the SAP ABAP standard function module HTTP_BASE64_ENCODE . With the usual online encoders, however, I got a different result.

How can I decode the encoded guid with JavaScript so that it has the desired format?

The string is in hexadecimal format you will have to convert it.

First you convert the string to binary (atob > charCodeAt) and then using the toString(16) you get the hex.

I will not post the code, since its already explained Decode Base64 to Hexadecimal string with javascript

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM