Will base64 encoded value exceed 65,535 characters

对着背影说爱祢 提交于 2020-03-25 16:19:39

问题


I am planning to convert pdf files to base64 encoded and save them in the database.

My DB column is text type.

Will base64 encoded value exceed 65,535 characters if pdf file is big?


回答1:


Base64 encoding maps the input bytes (8 Bit) to a 6 bit representation. That means, with a 4 character string in base64 encoding, you can encode 4 * 6 = 24 bits, which equals 3 byte of the unencoded original input. Therefore the result of the encoding will be 33% bigger than the input. And base64 encoding has no limits, so a 1MByte input will give you a 1.33MByte output.

As Sami mentioned in the comment, 49151byte input will result in 65535 bytes output.



来源:https://stackoverflow.com/questions/59026008/will-base64-encoded-value-exceed-65-535-characters

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!