簡體   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