[jcifs] how to create sambaLMPassword/sambaNTPassword password

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


Hi

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{
        //http://comments.gmane.org/gmane.network.samba.java/8580
        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));
            System.out.println(ntHash);
        }
        catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }     
        SecretKey key = KeyGenerator.getInstance("DES").generateKey();
        Cipher cipher = Cipher.getInstance("DES");
        cipher.init(Cipher.ENCRYPT_MODE, key);
        byte[] encryptedBytes = cipher.doFinal( password1.getBytes() );
        System.out.println(encryptedBytes);
    }
-------------- 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