Package io.github.enxign.shed.cipher
Class AES256
java.lang.Object
io.github.enxign.shed.cipher.AES256
AES256
- Since:
- 2021-02-01
- Version:
- 1.0
수정일 수정자 수정내용 ---------- --------- ------------------------------- 2021-02-01 first create
- Author:
- enxign
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
bytesToHex
(byte[] bytes) 바이트를 핵사값으로 변환static String
AES256 복호화 Cipher Mode : CBC (Cipher Block Chaining)static String
decryptECB
(String strVal, String AES256_KEY) AES256 복호화 Cipher Mode : ECB (Electronic CodeBook)static String
decryptHex
(String strVal, String secretKey, String IV) 복호화 핵사값static String
decryptUrl
(String strVal, String secretKey, String IV) url 복호화static String
AES256 암호화 Cipher Mode : CBC (Cipher Block Chaining) * Padding Mode : PKCS7 (*주의: JAVA document에서 명칭이 PKCS5이지만 내부동작은 PKCS7으로 함)static String
encryptECB
(String strVal, String AES256_KEY) AES256 암호화 Cipher Mode : ECB (Electronic CodeBook) Padding Mode : PKCS7 (*주의: JAVA document에서 명칭이 PKCS5이지만 내부동작은 PKCS7으로 함)static String
encryptHex
(String strVal, String secretKey, String IV) 암호화 핵사값static String
encryptUrl
(String strVal, String secretKey, String IV) url 암호화static byte[]
hexToBytes
(String hex) 핵사값을 바이트로 변환
-
Constructor Details
-
AES256
public AES256()
-
-
Method Details
-
encrypt
public static String encrypt(String strVal, String secretKey, String IV) throws UnsupportedEncodingException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException AES256 암호화 Cipher Mode : CBC (Cipher Block Chaining) * Padding Mode : PKCS7 (*주의: JAVA document에서 명칭이 PKCS5이지만 내부동작은 PKCS7으로 함)- Parameters:
strVal
- 암호화 할 문자열secretKey
- AES 암호화를 하는데 사용되는 Key는 16, 24, 32 byte 여야 한다.IV
- AES 암호화를 하는데 사용되는 Key는 16, 24, 32 byte 여야 한다.- Returns:
- 암호화 된 문자열
- Throws:
UnsupportedEncodingException
- 예외처리NoSuchAlgorithmException
- 예외처리NoSuchPaddingException
- 예외처리InvalidKeyException
- 예외처리InvalidAlgorithmParameterException
- 예외처리IllegalBlockSizeException
- 예외처리BadPaddingException
- 예외처리
-
encryptECB
AES256 암호화 Cipher Mode : ECB (Electronic CodeBook) Padding Mode : PKCS7 (*주의: JAVA document에서 명칭이 PKCS5이지만 내부동작은 PKCS7으로 함)- Parameters:
strVal
- 암호화 할 문자열AES256_KEY
- AES 암호화를 하는데 사용되는 Key는 16, 24, 32 byte 여야 한다.- Returns:
- 암호화 된 문자열
-
decrypt
public static String decrypt(String strVal, String secretKey, String IV) throws UnsupportedEncodingException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException AES256 복호화 Cipher Mode : CBC (Cipher Block Chaining)- Parameters:
strVal
- 암호화 된 문자열secretKey
- AES 암호화를 하는데 사용되는 Key는 16, 24, 32 byte 여야 한다.IV
- AES 암호화를 하는데 사용되는 Key는 16, 24, 32 byte 여야 한다.- Returns:
- 복호화 된 문자열
- Throws:
UnsupportedEncodingException
- 예외처리NoSuchAlgorithmException
- 예외처리NoSuchPaddingException
- 예외처리InvalidKeyException
- 예외처리InvalidAlgorithmParameterException
- 예외처리IllegalBlockSizeException
- 예외처리BadPaddingException
- 예외처리
-
decryptECB
AES256 복호화 Cipher Mode : ECB (Electronic CodeBook)- Parameters:
strVal
- 암호화 된 문자열AES256_KEY
- AES 암호화를 하는데 사용되는 Key는 16, 24, 32 byte 여야 한다.- Returns:
- 복호화 된 문자열
-
encryptUrl
public static String encryptUrl(String strVal, String secretKey, String IV) throws UnsupportedEncodingException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException url 암호화- Parameters:
strVal
- 암호화 할 문자열secretKey
- AES 암호화를 하는데 사용되는 Key는 16, 24, 32 byte 여야 한다.IV
- AES 암호화를 하는데 사용되는 Key는 16, 24, 32 byte 여야 한다.- Returns:
- 암호화 된 문자열
- Throws:
UnsupportedEncodingException
- 예외처리NoSuchAlgorithmException
- 예외처리NoSuchPaddingException
- 예외처리InvalidKeyException
- 예외처리InvalidAlgorithmParameterException
- 예외처리IllegalBlockSizeException
- 예외처리BadPaddingException
- 예외처리
-
decryptUrl
public static String decryptUrl(String strVal, String secretKey, String IV) throws UnsupportedEncodingException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException url 복호화- Parameters:
strVal
- 암호화 된 문자열secretKey
- AES 암호화를 하는데 사용되는 Key는 16, 24, 32 byte 여야 한다.IV
- AES 암호화를 하는데 사용되는 Key는 16, 24, 32 byte 여야 한다.- Returns:
- 복호화 된 문자열
- Throws:
UnsupportedEncodingException
- 예외처리NoSuchAlgorithmException
- 예외처리NoSuchPaddingException
- 예외처리InvalidKeyException
- 예외처리InvalidAlgorithmParameterException
- 예외처리IllegalBlockSizeException
- 예외처리BadPaddingException
- 예외처리
-
encryptHex
public static String encryptHex(String strVal, String secretKey, String IV) throws UnsupportedEncodingException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException 암호화 핵사값- Parameters:
strVal
- 암호화 할 문자열secretKey
- AES 암호화를 하는데 사용되는 Key는 16, 24, 32 byte 여야 한다.IV
- AES 암호화를 하는데 사용되는 Key는 16, 24, 32 byte 여야 한다.- Returns:
- 암호화 된 Hex값
- Throws:
UnsupportedEncodingException
- 예외처리NoSuchAlgorithmException
- 예외처리NoSuchPaddingException
- 예외처리InvalidKeyException
- 예외처리InvalidAlgorithmParameterException
- 예외처리IllegalBlockSizeException
- 예외처리BadPaddingException
- 예외처리
-
decryptHex
public static String decryptHex(String strVal, String secretKey, String IV) throws UnsupportedEncodingException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException 복호화 핵사값- Parameters:
strVal
- 복호화 할 문자열secretKey
- AES 암호화를 하는데 사용되는 Key는 16, 24, 32 byte 여야 한다.IV
- AES 암호화를 하는데 사용되는 Key는 16, 24, 32 byte 여야 한다.- Returns:
- 복호화 된 바이트값
- Throws:
UnsupportedEncodingException
- 예외처리NoSuchAlgorithmException
- 예외처리NoSuchPaddingException
- 예외처리InvalidKeyException
- 예외처리InvalidAlgorithmParameterException
- 예외처리IllegalBlockSizeException
- 예외처리BadPaddingException
- 예외처리
-
bytesToHex
바이트를 핵사값으로 변환- Parameters:
bytes
- 변환 될 문자열- Returns:
- 변환한 문자열
-
hexToBytes
핵사값을 바이트로 변환- Parameters:
hex
- 변환 될 핵사값- Returns:
- 변환한 바이트
-