From dba7f5f3b9e21ad1c51972d7180137b2755e05fc Mon Sep 17 00:00:00 2001 From: Sangbum Kim Date: Mon, 10 Oct 2016 15:38:47 +0900 Subject: [PATCH] iteration 2 -> 4096 --- build.gradle | 4 ++-- settings.gradle | 1 + src/main/java/Obfuscator.java | 2 +- src/main/java/SimpleEncryptor.java | 2 +- src/main/java/SimpleObfuscator.java | 23 +++++++++++++++-------- 5 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 settings.gradle diff --git a/build.gradle b/build.gradle index 713ae23..d1c1d39 100644 --- a/build.gradle +++ b/build.gradle @@ -13,8 +13,8 @@ buildscript { } } -mainClassName = 'Main' -//mainClassName = 'SimpleObfuscator' +//mainClassName = 'Main' +mainClassName = 'SimpleObfuscator' //mainClassName = 'Crypt' diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..ab2ba8f --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'simple-encryptor' diff --git a/src/main/java/Obfuscator.java b/src/main/java/Obfuscator.java index c538943..bcafc10 100644 --- a/src/main/java/Obfuscator.java +++ b/src/main/java/Obfuscator.java @@ -13,6 +13,6 @@ } public byte[] unobfuscate(byte[] source) { - return obfuscator.unobfuscate(encryptor.decrypt(source)); + return obfuscator.unobfuscate(encryptor.decrypt(source)); } } diff --git a/src/main/java/SimpleEncryptor.java b/src/main/java/SimpleEncryptor.java index 06240be..a2c44f7 100644 --- a/src/main/java/SimpleEncryptor.java +++ b/src/main/java/SimpleEncryptor.java @@ -38,7 +38,7 @@ public class SimpleEncryptor { //PBKDF2WithHmacSHA256 final PKCS5S2ParametersGenerator gen = new PKCS5S2ParametersGenerator(new SHA256Digest()); - gen.init(keyValue, salt, 2); + gen.init(keyValue, salt, 4096); final byte[] dk = ((KeyParameter) gen.generateDerivedParameters(256)).getKey(); SecretKey secret = new SecretKeySpec(dk, "AES"); diff --git a/src/main/java/SimpleObfuscator.java b/src/main/java/SimpleObfuscator.java index cf7393b..8295612 100644 --- a/src/main/java/SimpleObfuscator.java +++ b/src/main/java/SimpleObfuscator.java @@ -61,6 +61,9 @@ public class SimpleObfuscator { // "sha256/SlNzY+e3VjHNRXeCxFsG74HzSkjeZ3jbqoSYCD+nBcE=", // "sha256/klO23nT2ehFDXCfx3eHTDRESMz3asj1muO+4aIdjiuY=", // "sha256/grX4Ta9HpZx6tSHkmCrvpApTQGo67CYDnvprLg5yRME=" +// "WnEuMUmhEPwjPsFe864Ju7qTSQYHvvUs", +// "QF53h72JPMQ2vBuL", +// "9cPgDSmHe63z9zUu" // }; @@ -70,10 +73,11 @@ public class SimpleObfuscator { {-11, -95, 82, 80, 114, -61, -119, -35, -87, 38, 34, 79, -110, 5, 57, -93, -40, -83, 46, 53, -56, -86, -14, -114, 52, 95, 67, 5, -30, -91, -40, 43, -88, -5, -74, 11, 38, -84, -33, 89, -60, 64, 35, 1, 23, 66, 102, 54, 16, -116, 59, 51, 127, 55, 20, -103, 109, -52, -51, 106, 77, 83, 114, -118}, {-7, -12, -21, -123, -88, -7, 115, -14, -81, 102, -59, 101, -108, -55, 18, -101, -54, 73, 57, -1, 116, 17, -26, -2, 61, -75, 18, -47, 55, 64, -13, 25, 112, 113, 32, 80, -23, 119, 84, 24, 9, 25, -82, -115, 61, 35, 117, -20, -2, -83, 108, 25, 31, 45, 22, -29, -122, -33, 44, 11, -121, 85, 52, -4} }; - for (int i = 0; i < 1; i++) { + for (int i = 0; i < keys.length; i++) { // String sourceStr = keys[i]; - - byte[] selT = keys[i]; +// +// byte[] selT = sourceStr.getBytes(characterSet); + byte[] selT = keys[i]; // String output = new String(selT, 0, selT.length, characterSet); // @@ -97,19 +101,22 @@ public class SimpleObfuscator { // // log.append('\t'); - byte[] reout = soe.unobfuscate(selT); + byte[] reout = soe.unobfuscate(out); -// String outputRe = new String(reout, 0, reout.length, characterSet); - System.out.println(Arrays.toString(reout)); + String outputRe = new String(reout, 0, reout.length, characterSet); + System.out.println(outputRe); // if (!sourceStr.equals(outputRe)) { -// log.append(" NG\t"); +// System.out.println("NG"); +// }else{ +// System.out.println("OK"); +// // } // log.append('\n'); } - System.out.println(log.toString()); +// System.out.println(log.toString()); } }