-7
以下JavaScript的Bash版本是什么?这个JavaScript的等效Bash是什么?
// url-safe base64 encoding
function b64(bytes){
var str64 = typeof(bytes) === "string" ? window.btoa(bytes) : window.btoa(String.fromCharCode.apply(null, bytes));
return str64.replace(/\//g, "_").replace(/\+/g, "-").replace(/=/g, "");
}
特别是以下部分:
String.fromCharCode.apply(null, bytes)
我们也许可以帮助,如果你提供一个小的测试情况与样品的输入和预期输出从输入。对?祝你好运。 – shellter
@dknaack你真的需要在Bash中实现'b64()'吗?你不能使用'base64'命令吗? – Biffen
当字符串不会包含这些字符时,用base64编码的字符串替换所有的'/'和所有的'+'是什么意思? – PSkocik