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
Solved

MD5 Message Digest Example

Posted on 2014-02-04
2
446 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Spring Framework HTTPSession management 1 45
ejb example issues 3 26
jmss example java 2 23
Select statement in @Query (JPA Repository) - SpringMVC 2 14
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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 …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

837 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