Package com.poscoict.glueframework.util
Class GlueCipher
java.lang.Object
com.poscoict.glueframework.util.GlueCipher
파일/문자열 암복호화 클래스.
DES/ECB/PKCS5Padding -> AES/GCM/NoPadding 암호화 방식으로 변경
문자열 암호화시에는 암호화 문자열||IV(Initialization Vector) 함께 저장
파일 암호화 시에는 파일 앞 부분에 iv 저장해서 복호화시 이용
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String문자열 대칭 복호화.static String암호화된 문자열 복호화static voiddecryptFile(String infile, String outfile) 파일 대칭 복호화.static voiddecryptFile(String infile, String outfile, File key) decrypt filestatic String주어진 문자열을 GLUE_CIPHER_FILE로 암호화.static String주어진 문자열을 주어진 Key 파일로 암호화.static voidencryptFile(String infile, String outfile) 파일 대칭 암호화.static voidencryptFile(String infile, String outfile, File key) 암호키를 이용한 파일 암호화static File주어진 파일명으로 Key 생성
-
Field Details
-
GLUE_CIPHER_FILE
- See Also:
-
-
Constructor Details
-
GlueCipher
public GlueCipher()
-
-
Method Details
-
makekey
주어진 파일명으로 Key 생성- Parameters:
filename- 전체경로- Returns:
- File key file
- Throws:
IOException- I/O ErrorNoSuchAlgorithmException- java security Error
-
encrypt
public static String encrypt(String unencryptedString) throws BadPaddingException, IllegalBlockSizeException, InvalidAlgorithmParameterException, InvalidKeyException 주어진 문자열을 GLUE_CIPHER_FILE로 암호화.- Parameters:
unencryptedString- 비밀키 암호화를 희망하는 문자열- Returns:
- 암호화된 문자열
- Throws:
BadPaddingExceptionIllegalBlockSizeExceptionInvalidAlgorithmParameterExceptionInvalidKeyException
-
encrypt
public static String encrypt(String unencryptedString, File key) throws InvalidKeyException, BadPaddingException, IllegalBlockSizeException, FileNotFoundException, InvalidAlgorithmParameterException 주어진 문자열을 주어진 Key 파일로 암호화.- Parameters:
unencryptedString- 암호화 대상 문자열key- SecretKey- Returns:
- 암호화 된 문자열
- Throws:
InvalidKeyExceptionBadPaddingExceptionIllegalBlockSizeExceptionFileNotFoundExceptionInvalidAlgorithmParameterException
-
decrypt
public static String decrypt(String encryptedString) throws BadPaddingException, IllegalBlockSizeException, InvalidAlgorithmParameterException, InvalidKeyException 문자열 대칭 복호화.- Parameters:
encryptedString- 비밀키 복호화를 희망하는 문자열- Returns:
- String 복호화된 ID
- Throws:
BadPaddingExceptionIllegalBlockSizeExceptionInvalidAlgorithmParameterExceptionInvalidKeyException
-
decrypt
public static String decrypt(String encryptedString, File key) throws InvalidKeyException, BadPaddingException, IllegalBlockSizeException, InvalidAlgorithmParameterException 암호화된 문자열 복호화- Parameters:
encryptedString- 복호화를 희망하는 문자열key- 비밀키- Returns:
- String 복호화된 문자열
- Throws:
InvalidKeyExceptionBadPaddingExceptionIllegalBlockSizeExceptionInvalidAlgorithmParameterException
-
encryptFile
public static void encryptFile(String infile, String outfile) throws IOException, InvalidAlgorithmParameterException, InvalidKeyException 파일 대칭 암호화.- Parameters:
infile- 암호화를 희망하는 파일명outfile- 암호화된 파일명- Throws:
IOExceptionInvalidAlgorithmParameterExceptionInvalidKeyException
-
encryptFile
public static void encryptFile(String infile, String outfile, File key) throws IOException, InvalidAlgorithmParameterException, InvalidKeyException 암호키를 이용한 파일 암호화- Parameters:
infile-outfile-key-- Throws:
IOExceptionInvalidAlgorithmParameterExceptionInvalidKeyException
-
decryptFile
public static void decryptFile(String infile, String outfile) throws IOException, InvalidAlgorithmParameterException, InvalidKeyException 파일 대칭 복호화.- Parameters:
infile- 복호화를 희망하는 파일명outfile- 복호화된 파일명- Throws:
IOExceptionInvalidAlgorithmParameterExceptionInvalidKeyException
-
decryptFile
public static void decryptFile(String infile, String outfile, File key) throws IOException, InvalidAlgorithmParameterException, InvalidKeyException decrypt file- Parameters:
infile-outfile-key-- Throws:
IOExceptionInvalidAlgorithmParameterExceptionInvalidKeyException
-