有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何使用Apache Santuario xmlsec库加密/解密(旧版本)

我正在尝试编写一些代码,以使用旧的ApacheSantuario库版本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();
        }
    }
    
}

谢谢


共 (0) 个答案