我从外部网络得到一个 Base64 解码的字符串,我会将字符串转换为字节并解码。然后它将更改为 ASCII 格式。我将把这个 ASCII 存储在发送到另一台服务器的字符串中。在这种情况下,当我再次对 ASCII 进行编码时,我得到的值与我从外部网络收到的值不同。但它在 unix 系统中运行良好,问题仅在 windows 中。
// Base64 Encode
String orig = "mj5ok9qWt2v6fg3kElm8vZGeg9ZV0BqE1u2sYUQDEm8/heIdCH4ZRf7mcEcGkb8y3I24peAUBHdli8GP/MCZR/PG4NAAzd+AU3uEVM3RKTFnYwGslKQTfKgXzg+K+wkMY/0fexPkDrgVHi0vR7VXzcyx200iJYTYjJZLCwahZ7E2Cp7LW14YpCAYg8vFCp0XSZCe1luRNgq+q9xVQ88tDamAB5nGCxYZcx7X4D49HQR5vUEzIkJu2XenGQygXsGWICKv0UrVq72um0nRf0uJUa/jdMVXWtyeAsKTaVw8KTW5u745d+r7H3Fzcsl9UwL0kBfHv4WMQwz1dQ+MommXmA==";
byte [] decodedvalue = Base64.decodeBase64(orig.getBytes());
byte [] encodedvalue = Base64.encodeBase64(decodedvalue);
System.out.println("ORIGINAL VALUE : "+orig);
System.out.println("ENCODED VALUE : "+new String(encodedvalue));
String aa =new String(decodedvalue);
String temp = new String(Base64.encodeBase64(aa.getBytes()));
System.out.println(" String encoded value : " +temp);
ORIGINAL VALUE : mj5ok9qWt2v6fg3kElm8vZGeg9ZV0BqE1u2sYUQDEm8/heIdCH4ZRf7mcEcGkb8y3I24peAUBHdli8GP/MCZR/PG4NAAzd+AU3uEVM3RKTFnYwGslKQTfKgXzg+K+wkMY/0fexPkDrgVHi0vR7VXzcyx200iJYTYjJZLCwahZ7E2Cp7LW14YpCAYg8vFCp0XSZCe1luRNgq+q9xVQ88tDamAB5nGCxYZcx7X4D49HQR5vUEzIkJu2XenGQygXsGWICKv0UrVq72um0nRf0uJUa/jdMVXWtyeAsKTaVw8KTW5u745d+r7H3Fzcsl9UwL0kBfHv4WMQwz1dQ+MommXmA==
ENCODED VALUE : mj5ok9qWt2v6fg3kElm8vZGeg9ZV0BqE1u2sYUQDEm8/heIdCH4ZRf7mcEcGkb8y3I24peAUBHdli8GP/MCZR/PG4NAAzd+AU3uEVM3RKTFnYwGslKQTfKgXzg+K+wkMY/0fexPkDrgVHi0vR7VXzcyx200iJYTYjJZLCwahZ7E2Cp7LW14YpCAYg8vFCp0XSZCe1luRNgq+q9xVQ88tDamAB5nGCxYZcx7X4D49HQR5vUEzIkJu2XenGQygXsGWICKv0UrVq72um0nRf0uJUa/jdMVXWtyeAsKTaVw8KTW5u745d+r7H3Fzcsl9UwL0kBfHv4WMQwz1dQ+MommXmA==
String encoded value : mj5ok9qWt2v6fg3kElm8vZGeg9ZV0BqE1u2sYUQDEm8/heIdCH4ZRf7mcEcGkb8y3D+4peAUBHdli8E//MCZR/PG4NAAzd+AU3uEVM3RKTFnYwGslKQTfKgXzg+K+wkMY/0fexPkDrgVHi0vR7VXzcyx200iJYTYjJZLCwahZ7E2Cp7LW14YpCAYg8vFCj8XST+e1luRNgq+q9xVQ88tDamAB5nGCxYZcx7X4D49HQR5vUEzIkJu2XenGQygXsGWICKv0UrVq72um0nRf0uJUa/jdMVXWtyeAsKTaVw8KTW5u745d+r7H3Fzcsl9UwL0PxfHv4WMQwz1dQ+MommXmA==