BASE64减少需要连接$ C $位C的十进制数 [英] base64 to reduce digits required to encode a decimal number

查看:128
本文介绍了BASE64减少需要连接$ C $位C的十进制数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要管理某些对象的ID。
我需要这些ID是唯一的。
我有这些ID不能太长,在需要的数字项约束

时的base64是减少的数字编码的ID所需数量的好办法?

编辑:

  langage:C ++
数据类型:整数,然后转换成一个std :: string的


解决方案

在Base64的每个字符都可以重新present 6位,所以除以6的ID的长度,看看它有多少字符。二进制数据是每字节8位,这样它总是会较短,但字节不会所有人读取。

的Base64将使ID可读的,但它仍然如果ID必须手动输入,就像一个键也不会好。对于你要限制的字符集进一步

I have to manage an ID of some objects. I need these ID be unique. I have the constraint that these ID can't be too long in term of digits required

Is base64 is a nice way to reduce the number of digits required to encoding an ID ?

EDIT:

langage : c++
data type : integer , then convert in a std::string

解决方案

Each character in Base64 can represent 6 bits, so divide your ID length by 6 to see how many characters it will be. Binary data is 8 bits per byte so it will always be shorter, but the bytes won't all be readable.

Base64 will make the ID readable, but it still won't be good if the ID needs to be hand entered, like a key. For that you'll want to restrict the character set further.

这篇关于BASE64减少需要连接$ C $位C的十进制数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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