js base64转二进制字符串

例: str = ’111111‘ 转换为二进制字符串的值为 '001100010011000100110001001100010011000100110001'

现在我需要处理base64文件,将base64转换为二进制字符串,使用JavaScript处理

网上很多现成的方法
https://blog.csdn.net/m0_56204836/article/details/115339632

望采纳^O^


function base64toBlob(base64,type) {  
    // 将base64转为Unicode规则编码
   let  bstr = atob(base64, type),  
     n = bstr.length,  
    u8arr = new Uint8Array(n);  
    while (n--) {  
        u8arr[n] = bstr.charCodeAt(n) // 转换编码后才可以使用charCodeAt 找到Unicode编码
    }  
    return new Blob([u8arr], {  
        type,
    })
}