Help needed to decode a base 64 text. This is some background info:
- via API I get the following json data that I save in Bubble DB:
"attachments": [
{
"attachment_id": "1517840981837.pdf",
"file_name": "file1.pdf",
"file_extension": "pdf",
"file_size": 586549,
"file_url": "{encrypted_url}",
"url_type": "DOWNLOAD_URL",
"attachment_type": "INVOICE",
"read_only": false,
"content_type": "binary/octet-stream",
"upload_time": "2018-02-05T14:29:43.989Z"
},
- as you can see the file_url is encrypted and this is an example of what I get :
4a4pSuhveX2xsYLg7Ebx4I4HaVmN75o+1BE1Gv7AJrOPeAzs0qJkxtACDbNxNo1J8M7d6zfmLOKK0+NxIocJqqMfFhIhGkVZaxY8w+hz3/t+kowiAZw3GOQoDr1TAqwFAin9U4Jcvt/og9b0O0CCWROuda0QJIoR8P21KmofpnoG1r/aQjnjz1DLj2GDZ94h5KKmVJRvpfMSO5SR2esgCbE3anRWoXOAPI+mVeKQC/BpMfVN70iEyMQL5toNGtDJUvc5bz7L/7bF/PcmwKx2+TCjHqGzti5YSfXZRqhIdzIHXyaHM/HZLpUkeJ91XWj7H2E+E+nsaejkXwpdIMP4JFM19eKocMi0qHCsSkjuj0eRk11s987lfWvGmmItnhT63rmfeBh5KSNmHHOwf4l9Xf27X5C6SXa6U92+Bwx+zNeavc2JsLa1jwVWdTntytFHFbmRwprqDD9tYZ0ZKuAY1iorVWFM7jO7RzmB9T5G9XHu88jBtn8iRk0wkbQ9PaftKel3YluDe5uGoSLLwkTYLF9GClzZEyqXTv4M0GRwIZfJqE582wIIDAHKjLOc1KQz14km+GG8w03PUQ5r3J945Whtc2uJntAIc+XnqIb1fwiI6dYj6vQHlw==
- the service provider knowledge base says this:
The Base64 string of the File URL encrypted by DES in ECB mode, Pkcs7 padding scheme and using [Token]
- they suggest to decrypt the attachment file url using the JavaScript library of crypto standards ‘CryptoJS’ like this
var internal_token = "<token>";
var file_url = "<file_url_encrypted>";
function decryptByDES(ciphertext, key) {
var keyHex = CryptoJS.enc.Utf8.parse(key);
// direct decrypt ciphertext
var decrypted = CryptoJS.DES.decrypt({
ciphertext: CryptoJS.enc.Base64.parse(ciphertext)
}, keyHex, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
});
return decrypted.toString(CryptoJS.enc.Utf8);
}
console.log("decrypted url:" + decryptByDES(file_url, internal_token))
I do have the token.
Question is : how do I get the decrypted URL in Bubble ?
Thanks for helping me out.