我正在尝试使用旧的Apache Santuario库版本xmlsec-1.2.1.jar 编写一些代码来加密/解密
有了这个简单的示例,我可以进行Base64 编码/解码,¿有人可以放大它来进行加密/解密吗?(尽可能简单)。
该库似乎专注于 xml,但我只需要加密/解密一个字符串。
package test;
import org.apache.xml.security.utils.Base64;
public class TestCifrado {
public static void main(String[] args) {
String plain = "safe3827_euuy";
System.out.println("plain: " + plain);
String encoded = "";
try {
encoded = Base64.encode(plain.getBytes());
System.out.println("encoded: " + encoded);
} catch (Exception e) {
e.printStackTrace();
}
String decoded = "";
try {
byte[] decodedBytes = Base64.decode(encoded);
decoded = new String(decodedBytes);
System.out.println("decoded: " + decoded);
} catch (Exception e) {
e.printStackTrace();
}
}
}
谢谢!