Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS Access
Database Tools
SQL Scripts & Samples
» Database Forum
» Slideshows
» Sitemap
Free Newsletters:
News Via RSS Feed

follow us on Twitter
Database Journal |DBA Support |SQLCourse |SQLCourse2

Featured Database Articles


Posted Jun 4, 2000

Using Java to Encrypt Passwords

By Les Smith

  • A set of Java classes for encrypting passwords
  • Uses the powerful java Cryptography API
  • Need to download JCE 1.2 from
    • Then make sure that you have placed jce1_2-do.jar in the CLASSPATH. You can decompress the jar, but then it expands into multiple paths and you have more configuration work to do. So just add the jar file to the CLASSPATH. The CLASSPATH can be changed in System/Environment tab in the Control Panel.
  • If you need a COM dll then use Visual J++ to put a COM wrapper around them. After you have created a COM object you can use an SQL Server stored procedure or an ASP page to invoke it.
  • Enciphering and ciphering data depend on having a key. If you change the key then all your passwords will not work. Also if someone can get your key they can get all your passwords. So the table or file holding the key must be guarded with extreme care.
  • The connection is made using the ODBC-JDBC Bridge, since this is the most available driver. However, for any real java database work you will need a commercial JDBC driver such as WebLogic.
    • Please make sure that your ODBC connection has the following unchecked: "Use ANSI nulls,padding and warning". If it is checked then you will have a string with nulls appended to the size of the VARCHAR.
  • The creates a command line program with a sampler of the methods available. Normally the calling program would have a web interface, but it is simpler to present it this way.
  • If you have further questions please contact me at
  • The classes:
    • used for connecting to the database
    • used for generating a key. You need to run at least once. If you run again you invalidate existing passwords.
    • used to encrypt a string using the generated key
    • a calling class. Calls encrypt or decrypt. Example: java passwordSecure les test. Argument 0 is the login name. Argument 1 is the password.
  • The tables:

MS SQL Archives

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
SQL 2005: SSIS: Error using SQL Server credentials poverty 3 August 17th, 07:43 AM
Need help changing table contents nkawtg 1 August 17th, 03:02 AM
SQL Server Memory confifuration bhosalenarayan 2 August 14th, 05:33 AM
SQL Server Primary Key and a Unique Key katty.jonh 2 July 25th, 10:36 AM

Thanks for your registration, follow us on our social networks to keep up-to-date