Class CipherServiceImpl

  • All Implemented Interfaces:
    tv.hd3g.commons.authkit.CipherService

    @Service
    public class CipherServiceImpl
    extends Object
    implements tv.hd3g.commons.authkit.CipherService
    See https://proandroiddev.com/security-best-practices-symmetric-encryption-with-aes-in-java-7616beaaade9
    • 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:
        getSecureRandom in interface tv.hd3g.commons.authkit.CipherService
      • cipherFromData

        public byte[] cipherFromData​(byte[] clearData)
        Specified by:
        cipherFromData in interface tv.hd3g.commons.authkit.CipherService
      • unCipherToData

        public byte[] unCipherToData​(byte[] rawData)
        Specified by:
        unCipherToData in interface tv.hd3g.commons.authkit.CipherService
      • cipherFromString

        public byte[] cipherFromString​(String text)
        Specified by:
        cipherFromString in interface tv.hd3g.commons.authkit.CipherService
      • unCipherToString

        public String unCipherToString​(byte[] rawData)
        Specified by:
        unCipherToString in interface tv.hd3g.commons.authkit.CipherService
      • byteToString

        public static final String byteToString​(byte[] b)
      • computeSHA3FromString

        public String computeSHA3FromString​(String text)
        Specified by:
        computeSHA3FromString in interface tv.hd3g.commons.authkit.CipherService