0
package sha;
import java.security.MessageDigest;
/**
 *
 * @author deepak
 */
public class Sha {
public static void main(String[] args) throws Exception{
                    MessageDigest sha = MessageDigest.getInstance("SHA-1");
                         byte [] i1 = args[0].getBytes("UTF8");
                          sha.update(i1);
                          byte[] hash = sha.digest();
                          System.out.println ("Result: Success");
            // Display plain text and digest
               System.out.println ("Original plain text was : " + args[0]);
                System.out.println ("Digested text is     : " + new String (hash));
                 System.out.println ("Program execution was successful ...");
        }
}

i am getting error in:
byte [] i1 = args[0].getBytes("UTF8");

line no. 12

plss help me to remove it...

Edited by Reverend Jim: Fixed formatting

2
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by Deepak20
0

Probably args[0] doesn't exist. This is the array of arguments passed to the program, so perhaps when you run the program with "java Sha" you should add whatever args are required, as in "java Sha arg1".

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.