我使用gSOAP来使用一个服务,我的基本身份验证字符串编码为两个不同的字符串,一个来自Linux32位,另一个来自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] = '\0';
Linux系统的代码运行良好。来自AS400的不起作用。我想这是一些AS400编码问题,但我不确定,而且访问AS400系统的权限有限,所以我无法跟踪很多。
发布于 2016-11-02 09:28:12
这是因为您正在转换一个字节序列,它表示在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表,我们可以看到这是同一个字符串。
https://stackoverflow.com/questions/40375791
复制相似问题