mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 15:13:55 +08:00
19 lines
715 B
Java
19 lines
715 B
Java
import xiaozhi.common.utils.SM2Utils;
|
|||
|
|
|
||
|
|
/** Tiny subprocess boundary used by the Python/Java SM2 interoperability tests. */
|
||
|
|
public final class Sm2InteropCli {
|
||
|
|
private Sm2InteropCli() {
|
||
|
|
}
|
||
|
|
|
||
|
|
public static void main(String[] args) {
|
||
|
|
if (args.length != 3) {
|
||
|
|
throw new IllegalArgumentException("usage: encrypt <public-key> <plaintext> | decrypt <private-key> <ciphertext>");
|
||
|
|
}
|
||
|
|
switch (args[0]) {
|
||
|
|
case "encrypt" -> System.out.print(SM2Utils.encrypt(args[1], args[2]));
|
||
|
|
case "decrypt" -> System.out.print(SM2Utils.decrypt(args[1], args[2]));
|
||
|
|
default -> throw new IllegalArgumentException("unknown operation: " + args[0]);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|