Avoid UnsupportedEncodingException & use const from StandardCharsets (#11948)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
committed by
GitHub
parent
3f54327d5a
commit
167f8ebc49
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
package org.openhab.binding.mihome.internal;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
@@ -55,13 +55,7 @@ public class EncryptionHelper {
|
||||
logger.warn("Failed to construct Cipher");
|
||||
return "";
|
||||
}
|
||||
SecretKeySpec keySpec;
|
||||
try {
|
||||
keySpec = new SecretKeySpec(key.getBytes("UTF8"), "AES");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.warn("Failed to construct SecretKeySpec");
|
||||
return "";
|
||||
}
|
||||
SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "AES");
|
||||
try {
|
||||
cipher.init(Cipher.ENCRYPT_MODE, keySpec, vector);
|
||||
} catch (InvalidKeyException | InvalidAlgorithmParameterException e) {
|
||||
|
||||
Reference in New Issue
Block a user