atob and btoa were mozzila specific and IE still doesn't properly support it (as of IE 10, not sure about 11) - but since you get correct (and even padded) string, I don't know what else could be.
Try matching '' and "" you have both in your attr function. Use either double or single quotes, not both.
Check this :
Stackoverflow server solution