[jcifs] how to create sambaLMPassword/sambaNTPassword password

everson santos everjava at yahoo.com.br
Fri Aug 12 09:21:00 MDT 2011


I'm trying to create a password sambaLMPassword and sambaNTPassword to save an user on ldap. I didn't find many codes about. I would like to know which classes of the jcifs I can use to do that... Some code would be helpful.

I found the code below, but I'm not sure if it is a realy ntpassword

    public static void ntpassword() throws Exception{
        String password1 = "test1234";
        String ntHash = "";
        MD4 md4 = new MD4();
        byte[] bpass;
        try {
            bpass = password1.getBytes("UnicodeLittleUnmarked");
            md4.engineUpdate(bpass, 0, bpass.length);
            byte[] hashbytes = new byte[32];
            hashbytes = md4.engineDigest();
            ntHash = new String(Hexdump.toHexString(hashbytes, 0,hashbytes.length * 2));
        catch (UnsupportedEncodingException e) {
        SecretKey key = KeyGenerator.getInstance("DES").generateKey();
        Cipher cipher = Cipher.getInstance("DES");
        cipher.init(Cipher.ENCRYPT_MODE, key);
        byte[] encryptedBytes = cipher.doFinal( password1.getBytes() );
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.samba.org/pipermail/jcifs/attachments/20110812/64db54d9/attachment.html>

More information about the jCIFS mailing list