将基数 32 位解码字符串转换为十进制



我有一个基数 32 位解码的字符串,现在我想解码该字符串我还想将任何字符串编码为基数 32 位解码字符串。有什么方法,任何算法(即使在 C 中)或任何 API 都可以解决这个问题。提前感谢。

我不确定我是否理解你的问题,但如果你想将一个以 32 为基数的数字转换为以 10(十进制)为基数的数字,请采取这个:

#include <stdio.h>                                                                                                                                          
#include <string.h>
#include <math.h>
#define BASE 32
unsigned int convert_number (const char *s) {
    unsigned int len = strlen(s) - 1;
    unsigned int result = 0;
    char start_ch = 0, ch;
    while(*s != '') {
        ch = *s;
        if (ch >= 'a') {
            start_ch = 'a' - 10;
        } else if (ch >= 'A') {
            start_ch = 'A' - 10;
        } else {
            start_ch = '0';
        }
        if(len >= 0)
            result += (ch - start_ch) * pow(BASE, len);
        else
            result += (ch - start_ch);
        ++s;
        --len;
    }
    return result;
}