Package com.tridion.crypto
Class Crypto
java.lang.Object
com.tridion.crypto.Crypto
Generic cryptography implementation.
-
Constructor Summary
ConstructorsConstructorDescriptionCrypto()Construct a Crypto instance with the default encryption provider.Crypto(KeyProvider keyProvider) Construct a Crypto instance with the given encryption provider. -
Method Summary
-
Constructor Details
-
Crypto
public Crypto()Construct a Crypto instance with the default encryption provider. -
Crypto
Construct a Crypto instance with the given encryption provider.- Parameters:
keyProvider- The encryption provider to use.
-
-
Method Details
-
encrypt
Encrypt the provided secret.- Parameters:
secret- The password or other secret to encrypt.- Returns:
- The encrypted version of the input.
- Throws:
GeneralSecurityException- If something goes wrong with the encryption (wrong key size/algorithm/etc).
-
decrypt
Decrypts the provided secret.- Parameters:
secret- The password or other secret to decrypt.- Returns:
- The decrypted version of the input.
- Throws:
GeneralSecurityException- If something goes wrong with the encryption (wrong key size/algorithm/etc).
-
decryptIfNecessary
Tries to decrypt the value if and only if this is necessary. This is, the value starts withENCRYPTED_PREFIXand has at least one character after.- Parameters:
value- value to be processed.- Returns:
- decrypted value.
- Throws:
GeneralSecurityException- in case of decryption error.
-