<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi<br><br>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.<br><br>I found the code below, but I'm not sure if it is a realy ntpassword<br><br> public static void ntpassword() throws Exception{<br> //http://comments.gmane.org/gmane.network.samba.java/8580<br> String password1 = "test1234";<br> String ntHash = "";<br> MD4 md4 = new MD4();<br> byte[] bpass;<br> try {<br>
bpass = password1.getBytes("UnicodeLittleUnmarked");<br> md4.engineUpdate(bpass, 0, bpass.length);<br> byte[] hashbytes = new byte[32];<br> hashbytes = md4.engineDigest();<br> ntHash = new String(Hexdump.toHexString(hashbytes, 0,hashbytes.length * 2));<br> System.out.println(ntHash);<br> }<br> catch (UnsupportedEncodingException e) {<br> e.printStackTrace();<br> } <br> SecretKey
key = KeyGenerator.getInstance("DES").generateKey();<br> Cipher cipher = Cipher.getInstance("DES");<br> cipher.init(Cipher.ENCRYPT_MODE, key);<br> byte[] encryptedBytes = cipher.doFinal( password1.getBytes() );<br> System.out.println(encryptedBytes);<br> }<br></td></tr></table>