How to base64 encode inside of javascript

前端 未结 4 1589
逝去的感伤
逝去的感伤 2020-12-07 23:23

I am trying to implement a simple script on a site that will return base64 encoded information from google\'s ajax API. This is what I am playing with so far:



        
4条回答
  •  盖世英雄少女心
    2020-12-08 00:02

    IE 10 & above and all latest browser

    Encode String

    var str = "raj";
    var enc = window.btoa(str); // cmFq
    

    Decode String

    var dec = window.atoa('cmFq'); // raj
    

    Or else you might have your own function on page. small blog with references

提交回复
热议问题