sensorconfig encryption
This commit is contained in:
parent
d9576bf275
commit
ffcc2407cb
|
@ -73,12 +73,13 @@ public class CentralSensorConfigService {
|
||||||
try {
|
try {
|
||||||
String sensorConfigJsonStr = this.objectMapper.writeValueAsString(sensorConfig);
|
String sensorConfigJsonStr = this.objectMapper.writeValueAsString(sensorConfig);
|
||||||
// gzip
|
// gzip
|
||||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
ByteArrayOutputStream bos = new ByteArrayOutputStream(sensorConfigJsonStr.length());
|
||||||
GZIPOutputStream gzip = new GZIPOutputStream(bos);
|
GZIPOutputStream gzip = new GZIPOutputStream(bos);
|
||||||
gzip.write(sensorConfigJsonStr.getBytes("UTF-8"));
|
gzip.write(sensorConfigJsonStr.getBytes("UTF-8"));
|
||||||
gzip.flush();
|
gzip.flush();
|
||||||
gzip.close();
|
gzip.close();
|
||||||
byte[] compressedByte = bos.toByteArray();
|
byte[] compressedByte = bos.toByteArray();
|
||||||
|
bos.close();
|
||||||
|
|
||||||
// DES encryption
|
// DES encryption
|
||||||
Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
|
Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
|
||||||
|
@ -100,20 +101,20 @@ public class CentralSensorConfigService {
|
||||||
* private String testDecrypt(String encryptKey, String encrypted) throws
|
* private String testDecrypt(String encryptKey, String encrypted) throws
|
||||||
* OverflowException { try { byte[] inputBytes =
|
* OverflowException { try { byte[] inputBytes =
|
||||||
* Base64.getDecoder().decode(encrypted);
|
* Base64.getDecoder().decode(encrypted);
|
||||||
*
|
*
|
||||||
* Cipher cipher = Cipher.getInstance("DES"); SecretKeyFactory keyFactory =
|
* Cipher cipher = Cipher.getInstance("DES"); SecretKeyFactory keyFactory =
|
||||||
* SecretKeyFactory.getInstance("DES"); DESKeySpec desKeySpec = new
|
* SecretKeyFactory.getInstance("DES"); DESKeySpec desKeySpec = new
|
||||||
* DESKeySpec(encryptKey.getBytes()); cipher.init(Cipher.DECRYPT_MODE,
|
* DESKeySpec(encryptKey.getBytes()); cipher.init(Cipher.DECRYPT_MODE,
|
||||||
* keyFactory.generateSecret(desKeySpec)); byte[] outputBytes =
|
* keyFactory.generateSecret(desKeySpec)); byte[] outputBytes =
|
||||||
* cipher.doFinal(inputBytes);
|
* cipher.doFinal(inputBytes);
|
||||||
*
|
*
|
||||||
* GZIPInputStream gis = new GZIPInputStream(new
|
* GZIPInputStream gis = new GZIPInputStream(new
|
||||||
* ByteArrayInputStream(outputBytes)); BufferedReader bf = new
|
* ByteArrayInputStream(outputBytes)); BufferedReader bf = new
|
||||||
* BufferedReader(new InputStreamReader(gis, "UTF-8")); String result = "";
|
* BufferedReader(new InputStreamReader(gis, "UTF-8")); String result = "";
|
||||||
* String line; while ((line = bf.readLine()) != null) { result += line; }
|
* String line; while ((line = bf.readLine()) != null) { result += line; }
|
||||||
*
|
*
|
||||||
* return result;
|
* return result;
|
||||||
*
|
*
|
||||||
* } catch (Exception e) { throw new OverflowException("", e); } }
|
* } catch (Exception e) { throw new OverflowException("", e); } }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user