sensorconfig encryption

This commit is contained in:
insanity 2018-07-02 21:10:49 +09:00
parent d9576bf275
commit ffcc2407cb

View File

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