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.miio.internal;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.MessageDigest;
|
||||
@@ -99,11 +99,7 @@ public class MiIoCrypto {
|
||||
SecretKeySpec keySpec = new SecretKeySpec(new byte[16], "AES");
|
||||
cipher.init(Cipher.DECRYPT_MODE, keySpec);
|
||||
byte[] decrypted = cipher.doFinal(cipherText);
|
||||
try {
|
||||
return new String(decrypted, "UTF-8").trim();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
return new String(decrypted).trim();
|
||||
}
|
||||
return new String(decrypted, StandardCharsets.UTF_8).trim();
|
||||
} catch (InvalidKeyException | NoSuchAlgorithmException | NoSuchPaddingException | IllegalBlockSizeException
|
||||
| BadPaddingException e) {
|
||||
throw new MiIoCryptoException(e.getMessage(), e);
|
||||
|
||||
Reference in New Issue
Block a user