CyberArmy University | Open Source Institute | CyberArmy Intelligence & Security | CyberArmy Services & Projects

Some things . . .


[Replies] [Reply] [View by Thread] [Help]
[Back To SNEAK Development Forum]

Posted by Cpt SAJChurchey On 2005-03-14 19:22:49
In Reply to Java - MD5 - First Draft Posted by Maj anvar On 2005-03-14 19:01:39

Cpt
Cpt SAJChurchey


Just a few minor details here and there. Some refactoring. Do you know anything about JUnit tests? Someobody will have to write a test for this to be included. Just FYI.
package net.cyberarmy.sneak.scheme;

import net.cyberarmy.sneak.Scheme;
import java.security.MessageDigest;

public class MD5Scheme implements Scheme{
   public String getNameKey() {
        return "scheme.MD5.name";
    }

    public String getDescriptionKey() {
        return "scheme.MD5.description";
    }

    /**
     * Creates an MD5 digest of the input string
     * @param input String -- The string we want to MD5.
     * @return String -- The result we get.
     */
    public String execute(String input) {
    
      if (input == null) return null;
      input = input.trim();
      if (input.length() == 0) return null;
      
      MessageDigest md = null;
      try {
         md = MessageDigest.getInstance("MD5");
      }
    
      // Eat the exception because it shouldn't happen.
      catch (Exception e) {
        return "Source-code Error";
      }
      // Input the text and return the MD5 into the result String.
      return new String(md.digest(input.getBytes()));
    }
}
Cpt SAJChurchey
C/O of
Editorial
OSI Staff edit0r
OSI Feedback Representative




Replies:


Guest:
Subject:
Message:
Signature:
Optional Image Link:
http://

CyberArmy::Forum v0.6
Generated In 0.02334 seconds


About Us | Privacy Policy | Mission Statement | Help