Solved

MD5 Message Digest Example

Posted on 2014-02-04
2
433 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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now