标题根据唯一id生成分享码
#include <math.h>
#include <string>
using namespace std;
const string share_code_62 = "1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
string create_share_code(uint64_t id)
{
string share_code = "";
while (id >= 62)
{
share_code = share_code_62[id % 62] + share_code;
id = id / 62;
}
if (id >= 0)
{
share_code = share_code_62[id] + share_code;
}
return share_code;
}
uint64_t decode_share_code(string share_code)
{
uint64_t id = 0;
uint16_t len = share_code.length();
for (int i = len; i > 0; i--)
{
id += share_code_62.find(share_code[i - 1]) * uint64_t(powl(62, len - i));
}
return id;
}