public.javadoc.org.spincast.plugins.crypto.SpincastCryptoUtils.html Maven / Gradle / Ivy
Show all versions of spincast-website Show documentation
SpincastCryptoUtils (org.spincast:spincast-framework 1.13.0 API)
org.spincast.plugins.crypto
Interface SpincastCryptoUtils
-
- All Known Implementing Classes:
- SpincastCryptoUtilsDefault
public interface SpincastCryptoUtils
Spincast Crypto utils
-
-
Method Summary
All Methods Instance Methods Abstract Methods
Modifier and Type
Method and Description
String
decrypt(String payload,
String secretKey)
Decrypts a string that was encrypted using
encrypt(String, String)
.
String
encrypt(String toEncrypt,
String secretKey)
Encrypts a string, using the given secret key and the
AES
algorithm.
String
generateNewHashSecureSalt()
Will generate a new secure salt that can
be used with
hashSecure(String, String)
.
String
hashSecure(String toHash,
String salt)
Will hash a string using BCrypt
.
boolean
isRestrictedCryptographyJavaVersion()
Is the current Java version cryptography restricted?
void
removeCryptographyRestrictions()
Tries to remove the Java cryptography restrictions.
-
-
Method Detail
-
encrypt
String encrypt(String toEncrypt,
String secretKey)
Encrypts a string, using the given secret key and the
AES
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 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.
-
decrypt
String decrypt(String payload,
String secretKey)
Decrypts a string that was encrypted using
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.
-
hashSecure
String hashSecure(String toHash,
String salt)
Will hash a string using BCrypt
. This is currently
a good way to hash passwords so they can be stored in a database.
You can use generateNewHashSecureSalt()
to generate a
new salt.
-
generateNewHashSecureSalt
String generateNewHashSecureSalt()
Will generate a new secure salt that can
be used with
hashSecure(String, String)
.
-
removeCryptographyRestrictions
void removeCryptographyRestrictions()
throws RuntimeException
Tries to remove the Java cryptography restrictions.
- Throws:
an
- Exception is the restrictions can't be removed.
RuntimeException
- See Also:
https://stackoverflow.com/a/22492582/843699
-
isRestrictedCryptographyJavaVersion
boolean isRestrictedCryptographyJavaVersion()
Is the current Java version cryptography restricted?
Copyright © 2019. All rights reserved.