Class SpincastCryptoUtilsDefault
- All Implemented Interfaces:
SpincastCryptoUtils
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]
Decrypts a string that was encrypted usingSpincastCryptoUtils.encrypt(String, String)
.Encrypts a string, using the given secret key and theAES
algorithm.Will generate a new secure salt that can be used withSpincastCryptoUtils.hashSecure(String, String)
.protected SpincastCryptoConfig
hashSecure
(String toHash, String salt) Will hash a string usingBCrypt
.protected void
init()
boolean
Is the current Java version cryptography restricted?void
From https://stackoverflow.com/a/22492582/843699
-
Field Details
-
logger
protected static final org.slf4j.Logger logger
-
-
Constructor Details
-
SpincastCryptoUtilsDefault
-
-
Method Details
-
getSpincastCryptoConfig
-
init
@Inject protected void init() -
encrypt
Description copied from interface:SpincastCryptoUtils
Encrypts a string, using the given secret key and theAES
algorithm.The generated encrypted payload is a string which is also base64 encoded so it can be used in urls, emails, etc.
You must use the associated
SpincastCryptoUtils.decrypt(String, String)
method to decrypt the resultind payload.IMPORTANT!: For this method to work, JCE policy files may be installed first, security must be configured properly, or security policy must be disabled using the
SpincastCryptoConfig.removeJavaCryptoRestrictionsOnInit()
configuration.- Specified by:
encrypt
in interfaceSpincastCryptoUtils
-
decrypt
Description copied from interface:SpincastCryptoUtils
Decrypts a string that was encrypted usingSpincastCryptoUtils.encrypt(String, String)
.IMPORTANT!: For this method to work, JCE policy files may be installed first, security must be configured properly, or security policy must be disabled using the
SpincastCryptoConfig.removeJavaCryptoRestrictionsOnInit()
configuration.- Specified by:
decrypt
in interfaceSpincastCryptoUtils
-
buildKey
-
hashSecure
Description copied from interface:SpincastCryptoUtils
Will hash a string usingBCrypt
. This is currently a good way to hash passwords so they can be stored in a database.You can use
SpincastCryptoUtils.generateNewHashSecureSalt()
to generate a new salt.- Specified by:
hashSecure
in interfaceSpincastCryptoUtils
-
generateNewHashSecureSalt
Description copied from interface:SpincastCryptoUtils
Will generate a new secure salt that can be used withSpincastCryptoUtils.hashSecure(String, String)
.- Specified by:
generateNewHashSecureSalt
in interfaceSpincastCryptoUtils
-
removeCryptographyRestrictions
public void removeCryptographyRestrictions()From https://stackoverflow.com/a/22492582/843699- Specified by:
removeCryptographyRestrictions
in interfaceSpincastCryptoUtils
-
isRestrictedCryptographyJavaVersion
public boolean isRestrictedCryptographyJavaVersion()Description copied from interface:SpincastCryptoUtils
Is the current Java version cryptography restricted?- Specified by:
isRestrictedCryptographyJavaVersion
in interfaceSpincastCryptoUtils
-