Solved

MD5 Message Digest Example

Posted on 2014-02-04
2
449 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
intellij error 2 33
Eclipse with various Java releases 7 51
Fast way to search item into Java Array (Rhino compatible) 2 39
What browser will run Java? 7 127
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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 learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

726 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