且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用JavaScript编码Base64,使用GET发送,使用PHP解码

更新时间:2023-02-11 11:18:21

因此在javascript中(使用URI编码进行了更新):

So in javascript (updated with encoding URI):

var myStr = "I am the string to encode";
var token = encodeURIComponent(window.btoa(myStr));

btoa示例

然后您应该能够将该base64编码的字符串添加到您的get请求中.

You should be then able to add that base64 encoded string to your get request.

然后在PHP中,检索请求后:

Then in PHP, after you retrieve the request:

<?php
   $str = 'VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==';
   echo base64_decode(urldecode($str));
?>

base64_decode文档