protected void useAlgorithm(String algorithm) throws NoSuchAlgorithmException {
     if (messageDigest == null || messageDigest.getAlgorithm() != algorithm) {
       messageDigest = MessageDigest.getInstance(algorithm);
     }
 
     if (encoder == null) {
       encoder = new BASE64Encoder();
     }
   }