Magento base64 encode and base64 decode with JavaScript

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

About 2 weeks ago I worked on extension for Image Selector in Magento admin forms and I had to use base64 decode and encode functions. Basically Magento backend was sending me base64 encoded string and I had to to use base64 decode function in order to decode the data. I was lucky because Magento Core Team already had implemented such a functionality in JS files and those files were loaded in admin interface.

We have base64 functions in:

  • js/mage/adminhtml/tools.js (exists >= Magento CE 1.4 versions)
  • js/mage/adminhtml/hash.js (exists in older and current Magento CE versions)

I preferred the implementation in tools.js because it’s more robust when we do some Magento and utf8 specific things and there were functions that helped me to decode base64 strings used in URL.
Continue reading “Magento base64 encode and base64 decode with JavaScript”

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone