| | |
| | | }
|
| | |
|
| | | public static int byteArrayToInt(byte[] b) {
|
| | | return (b[0] & 0xFF) * 256 * 256 * 256 + (b[1] & 0xFF) * 256 * 256 + (b[2] & 0xFF) * 256 + (b[3] & 0xFF);
|
| | | int i = (b[0] & 0xFF) * 256 * 256 * 256 + (b[1] & 0xFF) * 256 * 256 + (b[2] & 0xFF) * 256 + (b[3] & 0xFF);
|
| | | return i;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 解密
|
| | | *
|
| | | * @param contentByte 待解密待字符串hexStr
|
| | | * @param contentByte 密钥
|
| | | * @return
|
| | | */
|
| | | public static byte[] decrypt(byte[] contentByte) {
|
| | | try {
|
| | | //KEY转换
|
| | | Key key = new SecretKeySpec("HDLRDCENTER1985.".getBytes(), "AES");
|
| | | //解密
|
| | | Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
|
| | | IvParameterSpec ivps = new IvParameterSpec("HDLRDCENTER1985.".getBytes());
|
| | | cipher.init(Cipher.DECRYPT_MODE, key, ivps);
|
| | | byte[] result = cipher.doFinal(contentByte);
|
| | | return result;
|
| | | } catch (NoSuchAlgorithmException e) {
|
| | | LogUtils.e(e.getMessage());
|
| | | } catch (InvalidKeyException e) {
|
| | | LogUtils.e(e.getMessage());
|
| | | } catch (NoSuchPaddingException e) {
|
| | | LogUtils.e(e.getMessage());
|
| | | } catch (BadPaddingException e) {
|
| | | LogUtils.e(e.getMessage());
|
| | | } catch (IllegalBlockSizeException e) {
|
| | | LogUtils.e(e.getMessage());
|
| | | } catch (InvalidAlgorithmParameterException e) {
|
| | | LogUtils.e(e.getMessage());
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | }
|