public class SecurityUtils extends Object
SymmetricEncryption
Modifier and Type | Field and Description |
---|---|
static String |
HASH_MD5 |
static String |
HASH_SHA1 |
static String |
HASH_SHA256 |
static String |
HASH_SHA512 |
Modifier and Type | Method and Description |
---|---|
static String |
computeSambaLMPassword(String password)
Encrypt a password for samba, LMPassword version.
|
static String |
computeSambaNTPassword(String password)
Encrypt a password for samba, NTPassword version.
|
static String |
decrypt(String value)
Decrypt a base64 value.
|
static String |
encrypt(String value)
Encrypt a value.
|
static String |
hash(String type,
String value)
Hash a value within a supported hash type.
|
public static final String HASH_MD5
public static final String HASH_SHA1
public static final String HASH_SHA256
public static final String HASH_SHA512
public static String decrypt(String value) throws GeneralSecurityException, IOException
value
- The valueGeneralSecurityException
IOException
public static String encrypt(String value) throws GeneralSecurityException, IOException
value
- The valueGeneralSecurityException
IOException
public static String hash(String type, String value) throws NoSuchAlgorithmException
type
- A valid hash type: SecurityUtils.HASH_MD5, SecurityUtils.HASH_SHA1, SecurityUtils.HASH_SHA256 or SecurityUtils.HASH_SHA512value
- A value to hashNoSuchAlgorithmException
public static String computeSambaLMPassword(String password) throws UnsupportedEncodingException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException
password
- the password to encryptUnsupportedEncodingException
NoSuchPaddingException
NoSuchAlgorithmException
InvalidKeyException
BadPaddingException
IllegalBlockSizeException
public static String computeSambaNTPassword(String password) throws UnsupportedEncodingException, NoSuchAlgorithmException, NoSuchProviderException
password
- the password to encryptUnsupportedEncodingException
NoSuchProviderException
NoSuchAlgorithmException
Copyright © 2005-2024 LSC project. All Rights Reserved.