api开放钱包创建接口

This commit is contained in:
lu7213 committed 2026-10-10 08:46:53 -04:00
1 parent 658e6ccf1e
commit a2be79377b
26 files changed
+636 -4

No files matched your search

@@ -0,0 +1,28 @@
package com.ruoyi.system.security;
import javax.crypto.Cipher;
import javax.crypto.spec.OAEPParameterSpec;
import javax.crypto.spec.PSource;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.spec.MGF1ParameterSpec;
import java.util.Base64;
/** RSA-OAEP SHA-256 加解密工具。 */
public final class RsaCipherUtil {
private static final OAEPParameterSpec OAEP = new OAEPParameterSpec(
"SHA-256", "MGF1", MGF1ParameterSpec.SHA256, PSource.PSpecified.DEFAULT);
private RsaCipherUtil() { }
public static String rsaOaepEncrypt(byte[] key, PublicKey publicKey) throws Exception {
Cipher cipher = Cipher.getInstance(CryptoConstants.RSA_TRANSFORMATION);
cipher.init(Cipher.ENCRYPT_MODE, publicKey, OAEP);
return Base64.getEncoder().encodeToString(cipher.doFinal(key));
}
public static byte[] rsaOaepDecrypt(String value, PrivateKey privateKey) throws Exception {
Cipher cipher = Cipher.getInstance(CryptoConstants.RSA_TRANSFORMATION);
cipher.init(Cipher.DECRYPT_MODE, privateKey, OAEP);
return cipher.doFinal(Base64.getDecoder().decode(value));
}
}