Dear All,
Currently, I use cryptix32, JDK 1.4.2.08.
The same result with diffenrent input with the following code:
password 888 --> enscipt --> C910B030A8D5A386FA4E4977ED78AC87
password 999 --> enscipt --> C910B030A8D5A386FA4E4977ED78AC87
It is totally wrong, any body can help me.
Thanks so much.
package test;
import cryptix.provider.key.RawSecretKey;
import cryptix.util.core.Hex;
public class changepassword {
/**
* @param args
*/
public static void main(String[] args) {
try{
System.out.println(createEncryptedPassword("administrator","888"));
System.out.println(createEncryptedPassword("administrator","999"));
}catch(Exception e){
e.printStackTrace();
}
}
static private String createEncryptedPassword( String userid, String password) {
String cipherkey = password.toUpperCase();
String encryptionTarget = userid.toUpperCase();
if (cipherkey.length() > 24) {
cipherkey = cipherkey.substring(0, 24);
} else {
while ((cipherkey.length() % 24) != 0) {
cipherkey += " ";
}
}
RawSecretKey key = new RawSecretKey("DES", cipherkey.getBytes());
xjava.security.Cipher cipher = null;
byte[] ciphertext = null;
try {
cipher =
xjava.security.Cipher.getInstance("DES-EDE3/CBC", "Cryptix");
cipher.initEncrypt(key);
while ((encryptionTarget.length() % 16) != 0) {
encryptionTarget = encryptionTarget + " ";
}
ciphertext =
cipher.crypt(
Hex.fromString(Hex.toString(encryptionTarget.getBytes())));
} catch (Exception e) {
com.prudentialvn.util.Util.addToLog(e.getMessage());
return "" ;
}
return Hex.toString(ciphertext);
}
}