系统、网站、API站点,简单高效开发

平台介绍 >> js/jsfun/fnBase64.js  base64相关操作

js/jsfun/fnBase64.js  base64相关操作

    let t1 = fnTime_timestampMilli();
    //二维码
    let base64Img = fnBase64_imageQrcode("TEST", 400);
    //验证码,可以将验证码写入session中,或全局缓存。
    let validcode = fnBase64_imageValidCode("123465", 200, 30, 30, true, true, fnJsa_rootPath() + "/font/simfang.ttf")
    let validcode2 = fnBase64_imageValidCode("中国人水电费", 200, 30, 30, true, true)
    let validcode3 = fnBase64_imageValidCode("中国人水电费", 200, 30, 30, true, true, fnJsa_rootPath() + "/font/simfang.ttf")

    //保存base64图片
    fnBase64_Save(base64Img, fnJsa_rootPath() + "/aa.png", true)
    //保存base64数据
    let content = "iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQAQMAAAC6caSPAAAABlBMVEX///8AAABVwtN+AAABZklEQVR42uzaTW6DMBCG4UFdZMkROApHI0fzUXoEllkgpvIf2G5QqNQkdvR+m1K3T1aONR5GCCGEEEIIIYfRJPKls4z26VumZP0KgbyY3OLTqCLSq67ut2mN6z0E0gYZ7Aa/ebJlWi1XXSCQ9og9xiGQjyEXW5BAIK2RvSBxpHNLZ2sYCOQZ5NeNb/U7+S+XRAjk7SRL0rs4GwikDuKP8c5VF6rxGB+278PhyQ+B1EXCTr+oEV08d0vdfvsTCKR+4uropPowXbE0QyCvJj5295pQM9ur3mB/9AdnMgRSIUnfM7u/G3s+BzkeXRIhkNpIceNz/7sRkXvNYQikQlJ04TRu/qvEzT8/mFKDQKog+TiQbF24znXkTkwQQSDPIOl75PzGF0pnCKQxIkVLLXwKBNIgGTXrwi13m8MQSIUkn4E3snfhjDycUoNAKiHlOJBI1rs4M0EEgfwzIYQQQggh5GPzEwAA//9+9kekl/2/6QAAAABJRU5ErkJggg=="
    fnBase64_Save(content, fnJsa_rootPath() + "/bb.png")

    //处理base64内容
    let base64content = "5oiR5piv5Lit5Zu95Lq6dGVzdA==" //test 的base64值
    let result = fnUtil_base64ToString(base64content);
    console.log(result) //result:test

    let byteCotent = fnUtil_base64ToBytes( base64content)
    let txt = fnUtil_bytesToString(byteCotent)
    console.log("aaa:",  byteCotent, txt );

    let t2 = fnTime_timestampMilli();
    return fnRenderTemplate("/html/base64.html", {"img": base64Img,"validcode":validcode,"validcode2":validcode2,"validcode3":validcode3,"t":t2-t1})


前端代码:


备案号:闽ICP备20003806号     厦门市湖里区陈朝能网络技术工作室