From a93a972c0f05b2e080227a9f65627f07deb81198 Mon Sep 17 00:00:00 2001 From: CubeBit Date: Thu, 3 Aug 2023 23:42:04 +0200 Subject: [PATCH] * deleted unused imports Signed-off-by: CubeBit --- .../org/orinprojects/encryption/EncryptionUtil.java | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/server/src/main/java/org/orinprojects/encryption/EncryptionUtil.java b/server/src/main/java/org/orinprojects/encryption/EncryptionUtil.java index 849dca2..91fda87 100644 --- a/server/src/main/java/org/orinprojects/encryption/EncryptionUtil.java +++ b/server/src/main/java/org/orinprojects/encryption/EncryptionUtil.java @@ -5,7 +5,6 @@ import javax.crypto.spec.GCMParameterSpec; import javax.crypto.spec.SecretKeySpec; import java.security.*; import java.security.spec.InvalidKeySpecException; -import java.security.spec.PKCS8EncodedKeySpec; import java.security.spec.X509EncodedKeySpec; import java.util.Base64; @@ -34,10 +33,6 @@ public class EncryptionUtil { return Base64.getEncoder().encodeToString(publicKey.getEncoded()); } - public static String privateKeyToString(PrivateKey privateKey) { - return Base64.getEncoder().encodeToString(privateKey.getEncoded()); - } - public static PublicKey stringToPublicKey(String encodedKey) throws NoSuchAlgorithmException, InvalidKeySpecException { byte[] decodedKey = Base64.getDecoder().decode(encodedKey.getBytes()); X509EncodedKeySpec keySpec = new X509EncodedKeySpec(decodedKey); @@ -47,14 +42,6 @@ public class EncryptionUtil { return factory.generatePublic(keySpec); } - public static PrivateKey stringToPrivateKey(String encodedKey) throws NoSuchAlgorithmException, InvalidKeySpecException { - byte[] decodedKey = Base64.getDecoder().decode(encodedKey.getBytes()); - PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(decodedKey); - - KeyFactory kf = KeyFactory.getInstance("RSA"); - return kf.generatePrivate(keySpec); - } - public static String encryptWithRSA(String data, PublicKey publicKey) throws InvalidKeyException, NoSuchPaddingException, NoSuchAlgorithmException, IllegalBlockSizeException, BadPaddingException { Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding"); cipher.init(Cipher.ENCRYPT_MODE, publicKey);