Solved

MD5 Message Digest Example

Posted on 2014-02-04
2
438 Views
Last Modified: 2014-02-07
Hi,

I am trying below MD5 MessageDigest example.

http://www.avajava.com/tutorials/lessons/how-do-i-generate-an-md5-digest-for-a-string.html

when i run this program without passing argument i get console error as

String to MD5 digest should be first and only parameter


I wonder why we need to pass argument to get output.

please advise
Any links resources ideas highly appreciated. Thanks in advance
0
Comment
Question by:gudii9
2 Comments
 
LVL 14

Accepted Solution

by:
CPColin earned 250 total points
ID: 39833972
That's just how that code was designed. The person who made that example could have just as easily done this instead:

String original = "INSERT YOUR STRING HERE";

Open in new window


but using a command-line argument is more flexible, since you don't have to recompile every time you change the string.
0
 
LVL 6

Assisted Solution

by:Mahesh Bhutkar
Mahesh Bhutkar earned 250 total points
ID: 39835025
i run this program without passing argument i get console error as
String to MD5 digest should be first and only parameter

Since you are running the program without passing argument it shows error on console as per code written,
if (args.length != 1) {
        System.err.println("String to MD5 digest should be first and only parameter");
        return;
}

Open in new window


and the control returns back without doing anything ahead.

I wonder why we need to pass argument to get output.
That is expected by the program to work on MD5 Digest.
String original = args[0];

The program provides flexibility to pass runtime argument directly rather than hardcoding within a progam.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jar file executable 12 52
split string containing \r\n in Java 46 44
Java string replace 11 47
Facing this issue for maven proxy setting 2 12
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question