public class SpincastCryptoUtilsDefault extends Object implements SpincastCryptoUtils
| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
logger |
| Constructor and Description |
|---|
SpincastCryptoUtilsDefault(SpincastCryptoConfig spincastCryptoConfig) |
| Modifier and Type | Method and Description |
|---|---|
protected byte[] |
buildKey(String original) |
String |
decrypt(String encrypted,
String secretKey)
Decrypts a string that was encrypted using
SpincastCryptoUtils.encrypt(String, String). |
String |
encrypt(String toEncrypt,
String secretKey)
Encrypts a string, using the given secrte key and the
AES algorithm. |
protected SpincastCryptoConfig |
getSpincastCryptoConfig() |
protected void |
init() |
boolean |
isRestrictedCryptographyJavaVersion()
Is the current Java version cryptography restricted?
|
void |
removeCryptographyRestrictions()
From https://stackoverflow.com/a/22492582/843699
|
@Inject public SpincastCryptoUtilsDefault(SpincastCryptoConfig spincastCryptoConfig)
protected SpincastCryptoConfig getSpincastCryptoConfig()
@Inject protected void init()
public String encrypt(String toEncrypt, String secretKey)
SpincastCryptoUtilsAES 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.
encrypt in interface SpincastCryptoUtilspublic String decrypt(String encrypted, String secretKey)
SpincastCryptoUtilsSpincastCryptoUtils.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.
decrypt in interface SpincastCryptoUtilsprotected byte[] buildKey(String original)
public void removeCryptographyRestrictions()
removeCryptographyRestrictions in interface SpincastCryptoUtilshttps://stackoverflow.com/a/22492582/843699public boolean isRestrictedCryptographyJavaVersion()
SpincastCryptoUtilsisRestrictedCryptographyJavaVersion in interface SpincastCryptoUtilsCopyright © 2018. All rights reserved.