Package org.kissweb
Class Crypto
java.lang.Object
org.kissweb.Crypto
This class provides the ability to encrypt/decrypt strings and byte arrays with very strong (AES) encryption.
Author: Blake McBride
Date: 2/1/22
This class provides the ability to encrypt/decrypt strings and byte arrays with very strong (AES) encryption.
Date: 2/1/22
This class provides the ability to encrypt/decrypt strings and byte arrays with very strong (AES) encryption.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]Decrypt a byte array utilizing a slat and the default password.static StringDecrypt a string utilizing the passed in salt and the default password.static byte[]Decrypt a byte array utilizing the passed in salt and password.static StringDecrypt a string utilizing the passed in salt and password.static byte[]decryptWithRandomSalt(byte[] encryptedValue) static StringdecryptWithRandomSalt(String encryptedValue) Decrypt a string that was encrypted with random salt using the default password.static byte[]decryptWithRandomSalt(String password, byte[] encryptedValue) static StringdecryptWithRandomSalt(String password, String encryptedValue) Decrypt a string that was encrypted with random salt using the provided password.static byte[]encrypt(byte[] valueToEnc) Encrypt with the default password and no salt.static StringEncrypt using the default password and no salt.static byte[]Encrypt a byte array utilizing a salt and the default password.static StringEncrypt a string utilizing the passed in salt and the default password.static byte[]Encrypt a byte array utilizing the passed in salt and password.static StringEncrypt a string utilizing the passed in salt and password.static byte[]encryptWithRandomSalt(byte[] valueToEnc) Encrypt with the default password and random salt.static StringencryptWithRandomSalt(String valueToEnc) Encrypt using the default password and random salt.static byte[]encryptWithRandomSalt(String password, byte[] valueToEnc) Encrypt with the given password and random salt.static StringencryptWithRandomSalt(String password, String valueToEnc) Encrypt with a given password and random salt.static voidstatic voidsetDefaultPassword(String password) Set the default password.
-
Constructor Details
-
Crypto
public Crypto()
-
-
Method Details
-
encrypt
Encrypt a string utilizing the passed in salt and password.
Whilesaltandpasswordcan be any size, they are added together and only the first 32 bytes are used.- Parameters:
salt- the salt or nullpassword-valueToEnc-- Returns:
- Throws:
Exception
-
encrypt
Encrypt a string utilizing the passed in salt and the default password.- Parameters:
salt- the salt or nullvalueToEnc-- Returns:
- Throws:
Exception
-
encrypt
Encrypt using the default password and no salt.- Parameters:
valueToEnc-- Returns:
- Throws:
Exception
-
encryptWithRandomSalt
Encrypt with a given password and random salt.- Parameters:
password-valueToEnc-- Returns:
- Throws:
Exception
-
encryptWithRandomSalt
Encrypt using the default password and random salt.- Parameters:
valueToEnc-- Returns:
- Throws:
Exception
-
encrypt
Encrypt a byte array utilizing the passed in salt and password.
Whilesaltandpasswordcan be any size, they are added together and only the first 32 bytes are used.- Parameters:
salt- the salt or nullpassword-valueToEnc-- Returns:
- Throws:
Exception
-
encrypt
Encrypt a byte array utilizing a salt and the default password.- Parameters:
salt- the salt or nullvalueToEnc-- Returns:
- Throws:
Exception
-
encrypt
Encrypt with the default password and no salt.- Parameters:
valueToEnc-- Returns:
- Throws:
Exception
-
encryptWithRandomSalt
Encrypt with the given password and random salt.- Parameters:
password-valueToEnc-- Returns:
- Throws:
Exception
-
encryptWithRandomSalt
Encrypt with the default password and random salt.- Parameters:
valueToEnc-- Returns:
- Throws:
Exception
-
decrypt
Decrypt a string utilizing the passed in salt and password.
Whilesaltandpasswordcan be any size, they are added together and only the first 32 bytes are used.- Parameters:
salt- the salt or nullpassword-encryptedValue-- Returns:
- Throws:
Exception
-
decrypt
Decrypt a string utilizing the passed in salt and the default password.- Parameters:
salt- the salt or nullencryptedValue-- Returns:
- Throws:
Exception
-
decryptWithRandomSalt
Decrypt a string that was encrypted with random salt using the provided password.- Parameters:
password-encryptedValue-- Returns:
- Throws:
Exception
-
decryptWithRandomSalt
Decrypt a string that was encrypted with random salt using the default password.- Parameters:
encryptedValue-- Returns:
- Throws:
Exception
-
decrypt
Decrypt a byte array utilizing the passed in salt and password.
Whilesaltandpasswordcan be any size, they are added together and only the first 32 bytes are used.- Parameters:
salt- the salt or nullpassword-encryptedValue-- Returns:
- Throws:
Exception
-
decrypt
Decrypt a byte array utilizing a slat and the default password.- Parameters:
salt- the salt or nullencryptedValue-- Returns:
- Throws:
Exception
-
decryptWithRandomSalt
- Throws:
Exception
-
decryptWithRandomSalt
- Throws:
Exception
-
setDefaultPassword
Set the default password. This remains until it is changed.
The password can be any size greater than 0 but only a max of the first 32 bytes will be used.- Parameters:
password- the password
-
main
- Throws:
Exception
-