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

Java - MD5 - First Draft


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

Posted by Maj anvar On 2005-03-14 19:01:39
In Reply to Desktop Version Posted by CinC snarkles On 2005-02-15 17:19:31

Maj
Maj anvar



Ok, I found some time and decided to give MD5 a try, it does even give an output :), so feel free to comment.
import java.security.MessageDigest;

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

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

    /**
     * Default method to run this.
     * @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.
      String result = new String(md.digest(input.getBytes()));
      return result;
    }
}
Major Anvar
It's not who you are that makes you do things, it's why you do things that determines who you are.

-Vandread



Replies:


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

CyberArmy::Forum v0.6
Generated In 0.02313 seconds


About Us | Privacy Policy | Mission Statement | Help