对于以下代码,当我尝试对字符串进行 base64 编码时。
import org.apache.commons.codec.binary.Base64;
public class Codec {
public static void main(String[] args) {
String clrTxt = "Hello world";
String encodedTxt;
encodedText = new String(Base64.encodeBase64(clearText.getBytes()));
System.out.println("Encoded: " + encodedText);
System.out.println("Decoded:"
+ new String(Base64.decodeBase64(encodedText.getBytes())));
//
// output :
// Encoded: **SGVsbG8gd29ybGQ=**
// Decoded:Hello world
}
}
在编码的字符串中,当我尝试插入一些额外的字符时,比如说 --> "SGVsb* G8ASDFASDFASDFASDFASDF1234234 *gd29ybGQ=" -> 我得到一个包含一些变音字符的明文。有没有一种方法可以验证和克服这一点。请回复。提前致谢。