gpt4 book ai didi

c++ - 为什么 Debian 和 AS400 给出不同的 base64 编码字符串?

转载 作者:行者123 更新时间:2023-11-30 01:42:00 24 4
gpt4 key购买 nike

我正在使用 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] = '\0';

来自 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++ - 为什么 Debian 和 AS400 给出不同的 base64 编码字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40375791/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com