Package java.security

Examples of java.security.MessageDigest.digest()


     */
    protected static String getSHA1(byte[] data) {
        MessageDigest md;
        try {
            md = MessageDigest.getInstance("SHA-1");
            return convertBytesToString(md.digest(data));
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }
    }

View Full Code Here


    private static String getSHA1(byte[] data) {
        MessageDigest md;
        try {
            md = MessageDigest.getInstance("SHA-1");
            return convertBytesToString(md.digest(data));
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

                  byte[] encodedRecipient = ((PdfObject)recipients.getArrayList().get(i)).getBytes()
                  md.update(encodedRecipient);
                }
                if ((cryptoMode & PdfWriter.DO_NOT_ENCRYPT_METADATA) != 0)
                    md.update(new byte[]{(byte)255, (byte)255, (byte)255, (byte)255});
                encryptionKey = md.digest();
               
            } catch (Exception f) {
                throw new ExceptionConverter(f);
            }
        }
View Full Code Here

    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

      throw new ExceptionConverter(e);
    }
    long time = System.currentTimeMillis();
    long mem = Runtime.getRuntime().freeMemory();
    String s = time + "+" + mem + "+" + (seq++);
    return md5.digest(s.getBytes());
  }

  /**
   */
  public void setupByUserPassword(byte[] documentID, byte userPassword[],
View Full Code Here

              (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

        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 );
    }

    public static void main(String[] args) throws IOException, NoSuchAlgorithmException {
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

            messageDigest = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            throw UncheckedException.asUncheckedException(e);
        }
        messageDigest.update(scriptText.getBytes());
        return new BigInteger(1, messageDigest.digest()).toString(16);
    }

    public static byte[] createHash(File file) {
        MessageDigest messageDigest;
        try {
View Full Code Here

                instr.close();
            }
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
        return messageDigest.digest();
    }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.