Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7178629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:57:33+00:00 2026-05-28T16:57:33+00:00

In example here http://tomcat.apache.org/tomcat-7.0-doc/realm-howto.html#JDBCRealm the type of user_pass column is varchar(15) , while java.security.MessageDigest

  • 0

In example here http://tomcat.apache.org/tomcat-7.0-doc/realm-howto.html#JDBCRealm the type of user_pass column is varchar(15), while java.security.MessageDigest class takes and returns byte[]. Which conversion one should apply to password 'abcd' (for example) to convert it into MD5 digest, expected by Tomcat?

PS.

I have tried the following and it works (coincides with digest.bat result). The only question is the length now: the digest is longer, than 15 characters. Can I just change the table?

public class DigestRunner {

    /**
     * @param args
     * @throws NoSuchAlgorithmException 
     */
    public static void main(String[] args) throws NoSuchAlgorithmException {
        String password = "abcd";
        MessageDigest dig = MessageDigest.getInstance("MD5");

        System.out.println(toString(dig.digest(password.getBytes())));

    }


    public static String toString(byte[] ba)
    {
        StringBuilder hex = new StringBuilder(ba.length * 2);

        for(byte b : ba)
            hex.append(String.format("%02x", b));

        return hex.toString();
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:57:34+00:00Added an answer on May 28, 2026 at 4:57 pm

    varchar(15) is definitely too short for digest password but it’s usually enough for plaintext passwords. Just increase the size.

    I have used the following code for creating digest passwords:

    final MessageDigest messageDigest = java.security.MessageDigest.
            getInstance("SHA-256");
    final byte bin[] = messageDigest.digest(("admin").getBytes());
    System.out.println(Base64.encodeBase64String(bin));
    

    (Base64 from Apache Commons Codec)

    Furthermore, there is a digest.bat/digest.sh in Tomcat, check it on the page that you linked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I found this: http://tiles.apache.org/framework/tutorial/advanced/nesting-extending.html Here is the example: <definition name=myapp.homepage template=/layouts/classic.jsp> <put-attribute name=title
Here is an example of polymorphism from http://www.cplusplus.com/doc/tutorial/polymorphism.html (edited for readability): // abstract base
I tried to run example here http://download.oracle.com/javaee/6/tutorial/doc/gipzz.html and didnt work... There is a bug
Going from the example given here... http://ericswann.org/blog/archive/2009/04/06/linq-to-sql-datacontext-provider-revisited.aspx I'm trying to use the datacontext between
here is link to an example: http://techchorus.net/demos/jquery/hiding-input-elements-in-a-div.html It actally disables few elements on click
Take a look at the example here: http://www.brianhare.com/physics/so.html Take a look at console.log where
Check out my example here: http://timkjaerlange.com/foobar/test.html I'm currently trying to apply a class to
Here's an example: http://la.truxmap.com/marker?id=thesweetstruck&t=1267058348000 The widget on the right usually overflows unless i set
So here's what I'd like to do: access to http://example.com/ * would require the
I've been developing a site (for now is here as an example: http://neurotoxine.mine.nu/gloom ),

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.