Visit the main Sourceforge project page to download source code: JPTAPI Project Page Please click the logo below to let us know we have traffic: This security library provides a simple way to strength test your passwords. This library utilizes Java in order to take advantage of its platform independence and extensive threading support. In order to use the library, client code needs to implement one interface. IPCLChecker interface provides one method - check(byte[]), which returns true if the password is valid, or true if it's not. Client code can utilize whatever logic neccessary to validate the password. Here is a very simple example of IPCLChecker implementation. This example compares a generated password with a string "mypass" and returns true if strings are identical: import com.antbs.jptapi.IPLChecker; public class MyPCLChecker implements IPCLChecker { public boolean check(byte [] passwd) { // need to trim the string as the password buffer is filled with space characters String str = new String(passwd).trim(); if("mypass".equals(str)) { return true; } return false; } } Once you have an IPCLChecker implementation, you are ready to apply the library's functionality to strength test the password. The entry point is the PCL class. Class's constructor takes two parameters. One is a reference to the IPCLChecker implementation, and the other parameter is an integer specifying the most number of thread that you wish to utilize in the search. For simple cases, one or two threads seem to produce best results. More threads are needed if you IPCLChecker.check(byte[]) implementation does any sort of I/O. PCL exposes a doCheck() method, which does the work. This library checks passwords of maximum length of 20 characters. This number of characters makes it practially impossible for any application to try all combinations in any person's lifetime. However, short passwords (1-10 characters) are very feasible. If the doCheck() ever returns, client code may check the password it found by calling the getFoundPasswd() method to retrieve it. import com.antbs.jptapi.PCL; public static void main(String [] args) { // initialize the class with the example above and // allow it to use two worker threads PCL pcl = new PCL(new MyPCLChecker(), 2); pcl.doCheck(); String passwd = new String(pcl.getFoundPasswd()); System.out.println("Password: "+passwd); } |