为什么Debian和AS400给出不同的base64编码字符串
Why Debian and AS400 are giving different base64 encoded strings?
我使用gSOAP来使用服务,并且我将基本身份验证字符串编码为两个不同的字符串,一个来自linux 32位,另一个来自AS400。代码是一样的。我想这可能是使用EBCDIC的AS400,但我将其转换为ASCII,它给出了相同的结果。有人遇到过同样的问题吗?
这是Linux编码字符串:
c2FudGFuZGVyY29uc3VtZXI6Z2Vyc29hMg==
这是AS400编码字符串:
ooGVo4GVhIWZg5aVoqSUhZl6h4WZopaB8g==
编码代码:
if (!t)
t = (char*)soap_malloc(soap, output_length /*(n + 2) / 3 *
* 4 + 1 */);
if (!t)
return NULL;
p = t;
for (int i = 0, j = 0; i < input_length;) {
uint32_t octet_a = i < input_length ? (unsigned char)s[i++] : 0;
uint32_t octet_b = i < input_length ? (unsigned char)s[i++] : 0;
uint32_t octet_c = i < input_length ? (unsigned char)s[i++] : 0;
uint32_t triple = (octet_a << 0x10) + (octet_b << 0x08) + octet_c;
t[j++] = encoding_table[(triple >> 3 * 6) & 0x3F];
t[j++] = encoding_table[(triple >> 2 * 6) & 0x3F];
t[j++] = encoding_table[(triple >> 1 * 6) & 0x3F];
t[j++] = encoding_table[(triple >> 0 * 6) & 0x3F];
}
for (int i = 0; i < mod_table[input_length % 3]; i++)
t[output_length - 1 - i] = '=';
t[output_length - mod_table[input_length % 3] + 2] = ' ';
来自Linux系统的代码运行良好。AS400不起作用。我猜这是一些AS400编码问题,但我不确定,我对AS400系统的访问有限,所以我不能追踪很多。
这是因为您正在转换一个字节序列,该字节序列表示用EBCDIC编码的文本。
第一个字符串是以下字节:
115,97,110,116,97,110,100,101,114,99,111,110,115,117,109,101,114,58,103,101,114,115,111,97,50
在ASCII中解码为santanderconsumer:gersoa2
。顺便说一下,你现在必须更改密码。
第二个Base64字符串是以下字节:
162,129,149,163,129,149,132,133,153,131,150,149,162,164,148,133,153,122,135,133,153,162,150,129,242
检查https://en.wikipedia.org/wiki/EBCDIC上的EBCDIC表,可以看到这是同一个字符串。
相关文章:
- 解码 c++ 中以 base64 编码的大量数据
- CryptoPP vs PHP Base64 编码/解码
- 在FLTK中显示Base64编码图像
- qt base64编码/decode添加逃脱字符
- 同一图像的不同 base64 编码
- Windows API base64编码/解码
- 如何从连接的 SSL 会话获取 base64 编码证书 (PEM)
- md5 base64 编码器在 C++ 与 Java 中
- Arduino SHA1-HMAC 和 base64 编码与 Python 之间的问题
- 使用提升抛出异常进行 Base64 编码
- Base64 编码失败
- base64编码空终止符
- 为什么Debian和AS400给出不同的base64编码字符串
- c++ base64编码- PHP兼容
- C++中Base64编码函数的逐位移位
- 来自终端的Base64编码字符串
- 在Cocos2d-x中加载Base64编码图像
- 使用base64编码CV_32FC1 Mat数据
- 如何将二进制字符串转换为base64编码的数据
- cryptopp-base64编码/解码后的值不相同