20 package org.sleuthkit.autopsy.coreutils;
22 import java.util.Base64;
23 import javax.crypto.Cipher;
24 import javax.crypto.SecretKey;
25 import javax.crypto.SecretKeyFactory;
26 import javax.crypto.spec.PBEKeySpec;
27 import javax.crypto.spec.PBEParameterSpec;
28 import org.openide.util.NbBundle;
35 private static final char[]
TMP =
"hgleri21auty84fwe".toCharArray();
36 private static final byte[]
SALT = {(byte) 0xde, (byte) 0x33, (byte) 0x10, (byte) 0x12, (byte) 0xde, (byte) 0x33, (byte) 0x10, (byte) 0x12};
49 SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(
"PBEWithMD5AndDES");
50 SecretKey key = keyFactory.generateSecret(
new PBEKeySpec(TMP));
51 Cipher pbeCipher = Cipher.getInstance(
"PBEWithMD5AndDES");
52 pbeCipher.init(Cipher.ENCRYPT_MODE, key,
new PBEParameterSpec(SALT, 20));
53 return base64Encode(pbeCipher.doFinal(property.getBytes(
"UTF-8")));
54 }
catch (Exception ex) {
60 return Base64.getEncoder().encodeToString(bytes);
74 SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(
"PBEWithMD5AndDES");
75 SecretKey key = keyFactory.generateSecret(
new PBEKeySpec(TMP));
76 Cipher pbeCipher = Cipher.getInstance(
"PBEWithMD5AndDES");
77 pbeCipher.init(Cipher.DECRYPT_MODE, key,
new PBEParameterSpec(SALT, 20));
78 return new String(pbeCipher.doFinal(
base64Decode(property)),
"UTF-8");
79 }
catch (Exception ex) {
85 return Base64.getDecoder().decode(property);
static byte[] base64Decode(String property)
static String base64Encode(byte[] bytes)
static String convertTextToHexText(String property)
static String convertHexTextToText(String property)