Package VaxTodo.Models
Class AES_GCM_Athentication
java.lang.Object
VaxTodo.Models.AES_GCM_Athentication
Used for encrypting and decrypting string password with AES 256 Galois/Counter Mode and SHA256 as salt
- Since:
- v1.0.0
- Authors:
- Mohamed, Christian, Louis
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
static String
Take String password and returns encrypted string passwordprivate static SecretKey
getAESKey
(int keysize) private static SecretKey
getAESKeyFromPassword
(char[] password, byte[] salt) private static byte[]
getRandomNonce
(int numBytes) private static String
hex
(byte[] bytes) private static String
hexWithBlockSize
(byte[] bytes, int blockSize)
-
Field Details
-
ENCRYPT_ALGO
- See Also:
-
TAG_LENGTH_BIT
private static final int TAG_LENGTH_BIT- See Also:
-
IV_LENGTH_BYTE
private static final int IV_LENGTH_BYTE- See Also:
-
SALT_LENGTH_BYTE
private static final int SALT_LENGTH_BYTE- See Also:
-
UTF_8
-
-
Constructor Details
-
AES_GCM_Athentication
public AES_GCM_Athentication()
-
-
Method Details
-
encrypt
Take String password and returns encrypted string password- Parameters:
strPasswd
- string password- Returns:
- encrypted string password
- Throws:
Exception
- if password cannot be encrypted
-
decrypt
- Throws:
Exception
-
getRandomNonce
private static byte[] getRandomNonce(int numBytes) -
getAESKey
- Throws:
NoSuchAlgorithmException
-
getAESKeyFromPassword
private static SecretKey getAESKeyFromPassword(char[] password, byte[] salt) throws NoSuchAlgorithmException, InvalidKeySpecException -
hex
-
hexWithBlockSize
-