fix static method

This commit is contained in:
Timi
2025-12-26 15:52:00 +08:00
parent 7378078299
commit 42f0212a40
2 changed files with 6 additions and 6 deletions

View File

@ -22,7 +22,7 @@ public class Decryptor {
* @param key 密钥
* @return 解密结果
*/
public byte[] aes(String data, byte[] key) {
public static byte[] aes(String data, byte[] key) {
return aes(data.getBytes(), key);
}
@ -33,7 +33,7 @@ public class Decryptor {
* @param key 密钥
* @return 解密结果
*/
public byte[] aes(byte[] data, byte[] key) {
public static byte[] aes(byte[] data, byte[] key) {
try {
SecretKey secretKey = new SecretKeySpec(key, "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");

View File

@ -16,11 +16,11 @@ import java.security.NoSuchAlgorithmException;
*/
public class Encryptor {
public byte[] aesKey() {
public static byte[] aesKey() {
return aesKey(256);
}
public byte[] aesKey(int size) {
public static byte[] aesKey(int size) {
try {
KeyGenerator keyGen = KeyGenerator.getInstance("AES");
keyGen.init(size);
@ -37,7 +37,7 @@ public class Encryptor {
* @param key 密钥
* @return 加密结果
*/
public byte[] aes(String data, byte[] key) {
public static byte[] aes(String data, byte[] key) {
return aes(data.getBytes(), key);
}
@ -48,7 +48,7 @@ public class Encryptor {
* @param key 密钥
* @return 加密结果
*/
public byte[] aes(byte[] data, byte[] key) {
public static byte[] aes(byte[] data, byte[] key) {
try {
SecretKey secretKey = new SecretKeySpec(key, "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");