?
Solved

MD5 Message Digest Example

Posted on 2014-02-04
2
Medium Priority
?
506 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 1000 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 1000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month16 days, 2 hours left to enroll

850 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