繁体   English   中英

在 Java 中编码 base64 并在 C# 中解码

[英]Encoding base64 in Java and decoding in C#


Im having problems whith base64 between java and c#, im sending encoded string to a asp.net handler from an java urlconnection, i compare both strings, the one generated in java from byte array and the one received in asp.net first decoding and both are identical but after解码 c# 中的字节数组与 java 中的字节数组不相等。 我正在使用新的 sun.misc.BASE64Encoder().encode(javabytearray); 在 java 和 System.Convert.FromBase64String(encodedstring) 中; 在点网中。

来自 java:“[0] [-24] [56] [1] [-56] [41] [-29]......”
到 dotnet:“[0] [232] [56] [1] [200] [41] [227]......”

类似: 在 Java 中编码 base64 并在 C# 中解码
我不能在上面提出问题,因为它是一个问答网站,每次必须创建一个新问题时,都不能在另一个问题中提出问题。
多谢

byte在 C# 中未签名,在 Java 中签名。 Java byte-24的位模式等于 c# byte232的位模式。 所以你的代码应该是正确的。 如果您想验证这一点,请将 Java byte值转换为int并将256添加到负值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM