Class SpincastCryptoUtilsDefault
- All Implemented Interfaces:
SpincastCryptoUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
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 theAESalgorithm.Will generate a new secure salt that can be used withSpincastCryptoUtils.hashSecure(String, String).protected SpincastCryptoConfighashSecure(String toHash, String salt) Will hash a string usingBCrypt.protected voidinit()booleanIs the current Java version cryptography restricted?voidFrom 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:SpincastCryptoUtilsEncrypts a string, using the given secret key and theAESalgorithm.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:
encryptin interfaceSpincastCryptoUtils
-
decrypt
Description copied from interface:SpincastCryptoUtilsDecrypts 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:
decryptin interfaceSpincastCryptoUtils
-
buildKey
-
hashSecure
Description copied from interface:SpincastCryptoUtilsWill 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:
hashSecurein interfaceSpincastCryptoUtils
-
generateNewHashSecureSalt
Description copied from interface:SpincastCryptoUtilsWill generate a new secure salt that can be used withSpincastCryptoUtils.hashSecure(String, String).- Specified by:
generateNewHashSecureSaltin interfaceSpincastCryptoUtils
-
removeCryptographyRestrictions
public void removeCryptographyRestrictions()From https://stackoverflow.com/a/22492582/843699- Specified by:
removeCryptographyRestrictionsin interfaceSpincastCryptoUtils
-
isRestrictedCryptographyJavaVersion
public boolean isRestrictedCryptographyJavaVersion()Description copied from interface:SpincastCryptoUtilsIs the current Java version cryptography restricted?- Specified by:
isRestrictedCryptographyJavaVersionin interfaceSpincastCryptoUtils
-