什么是base64长度(以字节为单位)? [英] What is a base64 length in bytes?

查看:670
本文介绍了什么是base64长度(以字节为单位)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用Base64编码的文件有一定的文件长度。如何获得字节大小?

I have a file encoded in Base64 with a certain file length. How do I get the size in bytes?

示例:

var size= canvas.toDataURL();   

console.log(resizeCanvasURL.length);


// -> 132787  base64 length


推荐答案

Base64编码中的每个符号保持6位信息。普通文件中的每个符号保持8位。由于解码后您拥有相同数量的信息:

Each symbol in Base64 encoding holds 6 bits of information. Each symbol in normal file hold 8 bits. Since after decoding you have the same amount of information you need:

normal file size - 1000 bytes
base64 file size - 1333 bytes

这篇关于什么是base64长度(以字节为单位)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆