数字转64位算法 C++
char ECodeArray[64] = { 'a', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'q', 's', 'd', 'f', 'g', 'h',
'j', 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm', '0', '4', '1', '5', '3', '7', '2', '8', '9', '6', 'Q',
'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', 'X', 'C',
'V', 'B', 'N', 'M', '-', '*' };
inline string encodeCharTo64(__int64 Num, int R)
{
string remain = "";
__int64 temp;
do {
temp = Num%R;
remain += ECodeArray[temp];
Num /= R;
} while (Num >= 1);
reverse(remain.begin(), remain.end());
return remain;
};
inline __int64 decode64Char(char c) {
for (__int64 i = 0; i < sizeof(ECodeArray); i++) {
if (c == ECodeArray[i]) {
return i;
}
}
return -1;
};
inline CString decode64ToInt(string strCode) {
__int64 multiple = 1;
__int64 result = 0;
char c;
for (int i = 0; i < strCode.length(); i++) {
c = strCode.at(strCode.length() - i - 1);
result += decode64Char(c) * multiple;
multiple = multiple * 64;
}
CString strReturn;
strReturn.Format("%I64d", result);
while (m_nRegcodeLength - strReturn.GetLength() > 0)
{
strReturn = "0" + strReturn;
}
return strReturn;
}