Package java.security

Examples of java.security.MessageDigest


    logger.debug("isValidLicenseFile: Validation String Buffer: "+validationStringBuffer.toString());
    String validationKey = (String)properties.getProperty(LICENSE_FILE_SHA_KEY);
    try
    {
      MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
      messageDigest.update(validationStringBuffer.toString().getBytes());
      String newValidation = Base64.encode(messageDigest.digest());
      if (newValidation.equals(validationKey))
      {
        if (getMACAddress().equals(Settings.getInstance().getMACAddress()))
        {
          returnValue = true;
View Full Code Here


    documentID = createDocumentId();
    setupByUserPad(this.documentID, userPad, this.ownerKey, permissions);
  }

  public static byte[] createDocumentId() {
    MessageDigest md5;
    try {
      md5 = MessageDigest.getInstance("MD5");
    } catch (Exception e) {
      throw new ExceptionConverter(e);
    }
    long time = System.currentTimeMillis();
    long mem = Runtime.getRuntime().freeMemory();
    String s = time + "+" + mem + "+" + (seq++);
    return md5.digest(s.getBytes());
  }
View Full Code Here

          dic.put(PdfName.STRF, PdfName.DEFAULTCRYPTFILER);
          dic.put(PdfName.STMF, PdfName.DEFAULTCRYPTFILER);
        }
      }

      MessageDigest md = null;
      byte[] encodedRecipient = null;

      try {
        md = MessageDigest.getInstance("SHA-1");
        md.update(publicKeyHandler.getSeed());
        for (int i = 0; i < publicKeyHandler.getRecipientsSize(); i++) {
          encodedRecipient = publicKeyHandler.getEncodedRecipient(i);
          md.update(encodedRecipient);
        }
        if (!encryptMetadata)
          md.update(new byte[] { (byte) 255, (byte) 255, (byte) 255,
              (byte) 255 });
      } catch (Exception f) {
        throw new ExceptionConverter(f);
      }

      byte[] mdResult = md.digest();

      setupByEncryptionKey(mdResult, keyLength);
    } else {
      dic.put(PdfName.FILTER, PdfName.STANDARD);
      dic.put(PdfName.O, new PdfLiteral(PdfContentByte
View Full Code Here

        response.sendError( HttpURLConnection.HTTP_UNAUTHORIZED, Http.getStatusPhrase( HttpURLConnection.HTTP_UNAUTHORIZED ));
        return true;
    }

    private static String hashPassword(String password) throws NoSuchAlgorithmException {
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        byte[] md5password = md5.digest( password.getBytes() );
        BASE64Encoder encoder = new BASE64Encoder();
        return encoder.encode( md5password );
    }
View Full Code Here

                    case MD5:

                        // Compare hashed password
                        try {
                            MessageDigest digest = MessageDigest.getInstance("MD5");
                            String hashedPassword = getHexString(digest.digest(password.getBytes()));
                            return hashedPassword.equals(auth_password.toUpperCase());
                        }
                        catch (NoSuchAlgorithmException e) {
                            throw new UnsupportedOperationException("Unexpected lack of MD5 support.", e);
                        }
View Full Code Here

/**
* @author Hans Dockter
*/
public class HashUtil {
    public static String createHash(String scriptText) {
        MessageDigest messageDigest;
        try {
            messageDigest = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            throw UncheckedException.asUncheckedException(e);
        }
        messageDigest.update(scriptText.getBytes());
        return new BigInteger(1, messageDigest.digest()).toString(16);
    }
View Full Code Here

        messageDigest.update(scriptText.getBytes());
        return new BigInteger(1, messageDigest.digest()).toString(16);
    }

    public static byte[] createHash(File file) {
        MessageDigest messageDigest;
        try {
            messageDigest = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            throw UncheckedException.asUncheckedException(e);
        }
        try {
            byte[] buffer = new byte[4096];
            InputStream instr = new FileInputStream(file);
            try {
                while (true) {
                    int nread = instr.read(buffer);
                    if (nread < 0) {
                        break;
                    }
                    messageDigest.update(buffer, 0, nread);
                }
            } finally {
                instr.close();
            }
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
        return messageDigest.digest();
    }
View Full Code Here

        if (s.length() % 2 != 0) s = "0" + s;
        return s;
    }

    public static String MD5(String toEncode) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        MessageDigest digest = MessageDigest.getInstance("MD5");
        digest.update(toEncode.getBytes("ISO-8859-1"));
        return ByteUtils.toHex(digest.digest());
    }
View Full Code Here

        final String signature = buffer.toString();

        Long serialVersionUID = new Long(0L);
        try
        {
            MessageDigest md = MessageDigest.getInstance("SHA");
            byte[] hashBytes = md.digest(signature.getBytes());

            long hash = 0;
            for (int ctr = Math.min(hashBytes.length, 8) - 1; ctr >= 0; ctr--)
            {
                hash = (hash << 8) | (hashBytes[ctr] & 0xFF);
View Full Code Here

        final String signature = buffer.toString();

        Long serialVersionUID = new Long(0L);
        try
        {
            MessageDigest md = MessageDigest.getInstance("SHA");
            byte[] hashBytes = md.digest(signature.getBytes());

            long hash = 0;
            for (int ctr = Math.min(hashBytes.length, 8) - 1; ctr >= 0; ctr--)
            {
                hash = (hash << 8) | (hashBytes[ctr] & 0xFF);
View Full Code Here

TOP

Related Classes of java.security.MessageDigest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.