Package tv.hd3g.authkit.mod.service
Class CipherServiceImpl
- java.lang.Object
-
- tv.hd3g.authkit.mod.service.CipherServiceImpl
-
- All Implemented Interfaces:
CipherService
@Service public class CipherServiceImpl extends Object implements CipherService
See https://proandroiddev.com/security-best-practices-symmetric-encryption-with-aes-in-java-7616beaaade9
-
-
Constructor Summary
Constructors Constructor Description CipherServiceImpl(String base64secret, int ivSize, String transformation, int gCMParameterSpecLen)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StringbyteToString(byte[] b)byte[]cipherFromData(byte[] clearData)byte[]cipherFromString(String text)StringcomputeSHA3FromString(String text)RandomgetSecureRandom()byte[]unCipherToData(byte[] rawData)StringunCipherToString(byte[] rawData)
-
-
-
Constructor Detail
-
CipherServiceImpl
public CipherServiceImpl(@Value("${authkit.cipher_secret}") String base64secret, @Value("${authkit.cipher_ivsize:12}") int ivSize, @Value("${authkit.cipher_transformation:AES/GCM/NoPadding}") String transformation, @Value("${authkit.cipher_GCMParameterSpecLen:128}") int gCMParameterSpecLen) throws GeneralSecurityException- Throws:
GeneralSecurityException
-
-
Method Detail
-
getSecureRandom
public Random getSecureRandom()
- Specified by:
getSecureRandomin interfaceCipherService
-
cipherFromData
public byte[] cipherFromData(byte[] clearData)
- Specified by:
cipherFromDatain interfaceCipherService- Parameters:
clearData- will be wipe after call.
-
unCipherToData
public byte[] unCipherToData(byte[] rawData)
- Specified by:
unCipherToDatain interfaceCipherService
-
cipherFromString
public byte[] cipherFromString(String text)
- Specified by:
cipherFromStringin interfaceCipherService
-
unCipherToString
public String unCipherToString(byte[] rawData)
- Specified by:
unCipherToStringin interfaceCipherService
-
byteToString
public static final String byteToString(byte[] b)
-
computeSHA3FromString
public String computeSHA3FromString(String text)
- Specified by:
computeSHA3FromStringin interfaceCipherService
-
-