java.lang.Object
com.martiansoftware.nailgun.examples.Hash

public class Hash extends Object
Hashes the client's stdin to the client's stdout in the form of a hexadecimal string. Command line requires one parameter: either the name of the algorithm to use (e.g., "MD5"), or "?" to request a list of available algorithms.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final char[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private static Set
    getCryptoImpls(String serviceType)
    Provides a list of algorithms for the specified service (which, for our purposes, is "MessageDigest".
    static void
    Hashes client stdin, displays hash result to client stdout.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • HEXCHARS

      private static final char[] HEXCHARS
  • Constructor Details

    • Hash

      public Hash()
  • Method Details

    • getCryptoImpls

      private static Set getCryptoImpls(String serviceType)
      Provides a list of algorithms for the specified service (which, for our purposes, is "MessageDigest". This method was only very slightly adapted (to use a TreeSet) from the Java Almanac at http://javaalmanac.com/egs/java.security/ListServices.html
      Parameters:
      serviceType - The name of the service we're looking for. It's "MessageDigest"
    • nailMain

      public static void nailMain(NGContext context) throws NoSuchAlgorithmException, IOException
      Hashes client stdin, displays hash result to client stdout. Requires one command line parameter, either the name of the hash algorithm to use (e.g., "MD5") or "?" to request a list of available algorithms. Any exceptions become the problem of the user.
      Throws:
      NoSuchAlgorithmException
      IOException