Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem with cryptix32.jar

843811Oct 20 2006 — edited Oct 20 2006
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);
	}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 17 2006
Added on Oct 20 2006
2 comments
431 views