# Function to convert b64 to hex?

**URL:** <https://discourse.nodered.org/t/function-to-convert-b64-to-hex/51035>\
**Category:** General\
**Created:** [14 September 2021 23:09 UTC](https://discourse.nodered.org/t/function-to-convert-b64-to-hex/51035 "2021-09-14T23:09:11Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Djamel-png](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/djamel-png/32/47949_2.png) [@Djamel-png](https://discourse.nodered.org/u/Djamel-png)\
**Post date:** [14 September 2021 23:09 UTC](https://discourse.nodered.org/t/function-to-convert-b64-to-hex/51035/1 "2021-09-14T23:09:11Z")

</div>

Dear,  
I need to create a formula to convert b64 to hexa.  
Thanks in advances

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [15 September 2021 06:54 UTC](https://discourse.nodered.org/t/function-to-convert-b64-to-hex/51035/2 "2021-09-15T06:54:46Z")

</div>

### Base64 to Buffer (array of numbers)

`Buffer.from('AQIDBAU=', "base64")`  
→ \<Buffer 01 02 03 04 05\>

### Base64 to Hexadecimal String...

`Buffer.from('AQIDBAU=', "base64").toString("hex")`  
→ '0102030405'

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [15 September 2021 07:06 UTC](https://discourse.nodered.org/t/function-to-convert-b64-to-hex/51035/3 "2021-09-15T07:06:15Z")

</div>

Or use the node-red-node-base64 node

---

<div class="post-metadata">

**Author:** ![Djamel-png](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/djamel-png/32/47949_2.png) [@Djamel-png](https://discourse.nodered.org/u/Djamel-png)\
**Post date:** [8 October 2021 18:01 UTC](https://discourse.nodered.org/t/function-to-convert-b64-to-hex/51035/4 "2021-10-08T18:01:43Z")

</div>

Dear Expert,  
I have a issue to convert b64 to Hexa, I found the B64 convert but I didn't get a correct result  
Please I need your support and advise, thank you so much in advance.

.

 ![to convet 003](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/3/e3936564699e4b212b353838264590b1991e30b9.png)  
 ![to convet 004](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/7/b7a9c20eeaf1e44cbf81a6dfd5e9b85b99031a63.png)

---

<div class="post-metadata">

**Author:** ![Djamel-png](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/djamel-png/32/47949_2.png) [@Djamel-png](https://discourse.nodered.org/u/Djamel-png)\
**Post date:** [8 October 2021 18:02 UTC](https://discourse.nodered.org/t/function-to-convert-b64-to-hex/51035/5 "2021-10-08T18:02:30Z")

</div>

![to convet 002](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/e/9eaeb14f48bf567f902d1a38a15d3b42b7a1f2c7.png)  
 ![to convet 001](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/1/21c958e7fae91eb0efbf8260c61802e1edf2defb.png)

---

<div class="post-metadata">

**Author:** ![Djamel-png](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/djamel-png/32/47949_2.png) [@Djamel-png](https://discourse.nodered.org/u/Djamel-png)\
**Post date:** [11 October 2021 13:16 UTC](https://discourse.nodered.org/t/function-to-convert-b64-to-hex/51035/6 "2021-10-11T13:16:20Z")

</div>

Please can someone help me on this topic.  
To split the data in order to covert b64 to Hexa  
Thanks in advances

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [11 October 2021 15:15 UTC](https://discourse.nodered.org/t/function-to-convert-b64-to-hex/51035/7 "2021-10-11T15:15:30Z")

</div>

I showed you how to convert base64 string to hexadecimal string

> [@Function to convert b64 to hex?](https://discourse.nodered.org/t/fonction-to-convert-b64-to-hexa/51035/2):
>
> Base64 to Buffer (array of numbers) Buffer.from('AQIDBAU=', "base64") → \<Buffer 01 02 03 04 05\> Base64 to Hexadecimal String... Buffer.from('AQIDBAU=', "base64").toString("hex") → '0102030405'

> [@Djamel-png](#):
>
> To split the data in order to covert b64 to Hexa

What exactly does this mean?

Can you provide

- sample data (not a picture, but actual string/text that can be copied+pasted)
- what you expect it to become

e.g...

- data: `AQIDBAU=`
- expected result: `0102030405`

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [11 October 2021 15:36 UTC](https://discourse.nodered.org/t/function-to-convert-b64-to-hex/51035/8 "2021-10-11T15:36:26Z")

</div>

Anytime that you see red bars or boxes around your input fields, you have a configuration problem.

Notice that in your first screenshot, the `b64`node's Property field has `msg.` prefix selected... but in the value field you have typed `.data`?

Then in the debug sidebar, there is the error message (next to the red bar):

> "Error: Invalid property expression: unexpected . at position 0"

Try removing the leading "." from the b64 property...

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [10 December 2021 15:37 UTC](https://discourse.nodered.org/t/function-to-convert-b64-to-hex/51035/9 "2021-12-10T15:37:00Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
