Lijkt dus te gaan om een password based DES algoritme die het wachtwoord in MD5 gebruikt als Encr.key
Klinkt heel duidelijk... Ik snap er alleen niks van.
De java code is dit:
Java: 1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
| public static String generateUserActivationCode(String userRegCode, byte[]mac) {
byte[] ownKey = new byte[] { 59, 100, 83, 52, 109, 100, 57, 83, 39, 119, 122, 51, 71 };
byte [] keyToUse = makeKeytoUse(ownKey,mac);
byte [] encryptedData = decriptData(mac, keyToUse);
if(encryptedData == null){
return "Error while Generating activatie code";
}
return Base64CoderDecoder.encodeLines(encryptedData);
}
private static byte[] decriptData(byte[] mac, byte[] keyToUse) {
String macStr = toMacString('q', mac);
String totalStr = "pietjepuk"+macStr;
new String(keyToUse);
try {
PBEKeySpec pbeKeySpec = new PBEKeySpec(new String(keyToUse).toCharArray());
SecretKeyFactory skf = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
SecretKey key = skf.generateSecret(pbeKeySpec);
PBEParameterSpec paramSpec = new PBEParameterSpec(salt, Iterations);
// Create a cipher and initialize it for encrypting
Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES");
cipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
byte[] ciphertext = cipher.doFinal(totalStr.getBytes());
return ciphertext;
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchPaddingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidKeyException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (BadPaddingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidKeySpecException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidAlgorithmParameterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
} |
kan iemand me helpen hier wat in php uit te krijgen?
[
Voor 96% gewijzigd door
Verwijderd op 26-03-2010 15:55
. Reden: nieuwe info ]