Base64 decoding

Hi all! I’m receiving a string from an external source in my Bubble app and it’s encoded using base64 (I store this encoded string as a field in the User). I want to decode it, and I know the Javascript piece of code to be used “outside Bubble” is: var decodedString = atob(encodedString);

So:

  1. Is there a way to decode this automatically in Bubble (plugin, action…)?
  2. If not, how do I run the script above on Bubble (using ToolBox plugin) to decode the field and being able to use the output (the decoded text) in the next step of the workflow?

Thanks a lot!

I have a plugin that encodes/decodes base, encrypts/Decrypts AES and Generates HMAC-SHA1. I will put in up in the morning when in back at my machine.

2 Likes

OMG @jarrad you made my day! I will be looking forward! Thanks a lot! :smiley:

enc

Encode/Decode/Encrypt/Decrypt is ready @eurogar, Its available here

Encodes/Decodes Various Encryption & Encoding Methods. We will continue to add Ciphers, Encryption Methods & Encoding’s - Need a certain method? Head to our website and let us know…

@eurogar, I hope this helps you out with your project - PM me your app name and I will throw you a copy :slight_smile:

Merry Christmas.

3 Likes

@jarrad thanks a lot! :slight_smile: Really looking forward to test it in depth! :smiley:

More than welcome, Its been added :slight_smile:

I’m looking for a way to encrypt the text fields my users use. I realise that Bubble’s database architecture is very secure but I am looking for a way that I (the admin) can’t view my users data in the Bubble backend. Will this plugin allow me to encrypt a field before saving it to my database then decrypt it back for the user?

Yes it will, AES has been added already but if you require a different encryption type let me know and i will add it in.

@jarrad could the plugin generate HMAC SHA256?

HMAC-SHA256 is now added, also output’s are now non base64 encoded so if your using HMAC-SHA1 from now on add the Encode to Base64 action to the output. I will add a checkbox when I get some time.

1 Like

Updated, Now has HMAC-SHA 1 & 256, with base64 inc. header type eg. “Bearer Base64(clientid):base64(clientsecret) → secret key”, added URL Encoding/Decoding, added Escaping/Un-Escaping plus some other stuff.

image

2 Likes

@jarrad, here’s the use case I’m trying to build. See the note at the bottom. Just want to make sure the plugin is capable of this. It needs to base64-decode the secret, then combine it with other strings, and finally base64-encode.

Here’s the example code they have for NodeJS

var crypto = require('crypto');

var secret = 'PYPd1Hv4J6/7x...';

var timestamp = Date.now() / 1000;
var requestPath = '/orders';

var method = 'GET';

// create the prehash string by concatenating required parts
var what = timestamp + method + requestPath;

// decode the base64 secret
var key = Buffer(secret, 'base64');

// create a sha256 hmac with the secret
var hmac = crypto.createHmac('sha256', key);

// sign the require message with the hmac
// and finally base64 encode the result
return hmac.update(what).digest('base64');
1 Like

I just added a custom HMAC, if the result of this isnt what your after then its just a case of running the result through the base64 encode action. I will signup to coinbase when i get a chance and test it properly.

image

1 Like

Is there anything you can’t do? :wink:

1 Like

And it’s actually GDAX - https://docs.gdax.com/?javascript#api. This is Coinbase’s exchange.

2 Likes

Well in light of that i thought i better add a body in the sig for POST then :slight_smile:

image

1 Like

So that one dialog will take the inputs and then perform the decoding, concatenation, then encoding?

1 Like

This is the output of that action,

a436e92d4814416e47be4ffcef5bf3c3a40860a026307795a75186ee7e18e08f

if it turns out when i get to test that it still requires base encoding after the fact, then this is what’s returned,

YTQzNmU5MmQ0ODE0NDE2ZTQ3YmU0ZmZjZWY1YmYzYzNhNDA4NjBhMDI2MzA3Nzk1YTc1MTg2ZWU3ZTE4ZTA4Zg==

However there is also a base64 encode action in the plugin, it takes no longer to have that run - just reference the plugins output as the base64 input and the output will very quickly become the latter of the above.

1 Like

@jarrad , I’m totally confused on the steps to take. I’ve tried each of the actions and even combinations in the workflow, but it’s not clear what fields should be populated or what actions I should use.

Just place the Encode/Decode element on the page and then the Element Actions with show up.
You want the Custom HMAC.

image