📌  相关文章
📜  检查是否 base64 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:53.455000             🧑  作者: Mango

代码示例1
// How to check if a string is base64 encoded
// Originally from willnode https://stackoverflow.com/users/3908409/willnode

/* 
Checks if:
 - Length is divisible by 4
 - It uses A-Z, a-z, 0-9, +/=
 - Uses = at the end (within 0-3 characters)
*/

function isBase64(str) {
    return str.length % 4 == 0 && /^[A-Za-z0-9+/]+[=]{0,3}$/.test(str);
}