package edu.pdx.cs410J.security;

import java.security.*;

/**
 * This program computes the MD5 digest of a sentence specified on the
 * command line.
 */
public class PrintDigest {

  public static void main(String[] args) {
    String message = args[0];
    MessageDigest algorithm = null;
    try {
      algorithm = MessageDigest.getInstance("MD5");
    } catch (NoSuchAlgorithmException ex) {
      ex.printStackTrace(System.err);
      System.exit(1);
    }

    algorithm.reset();
    algorithm.update(message.getBytes());
    byte[] digest = algorithm.digest();

    StringBuffer hexString = new StringBuffer();
    for (int i = 0; i < digest.length; i++) {
      String s = Integer.toHexString(0xFF & digest[i]);
      hexString.append(s);
    }
    
    System.out.println("Message: " + message);
    System.out.println("Digest: " + hexString.toString());
  }
}

@@ -85,19 +85,19 @@
 tes the 
-MD5
+SHA
  digest 
@@ -243,16 +243,31 @@
 ge =
+ String.join(%22 %22,
  args
-%5B0%5D
+)
 ;%0A  
@@ -359,11 +359,11 @@
 ce(%22
-MD5
+SHA
 %22);%0A
@@ -591,18 +591,19 @@
 StringBu
-ff
+ild
 er hexSt
@@ -625,10 +625,11 @@
 ngBu
-ff
+ild
 er()
@@ -643,41 +643,23 @@
 or (
-int i = 0; i %3C digest.length; i++
+byte b : digest
 ) %7B%0A
@@ -706,17 +706,9 @@
 F & 
-digest%5Bi%5D
+b
 );%0A 
@@ -791,16 +791,16 @@
 ssage);%0A
+
     Syst
@@ -840,19 +840,8 @@
 ring
-.toString()
 );%0A 

Address #412 by using the "SHA" message digest algorithm.