Package java.security

Examples of java.security.MessageDigest.reset()


   */
  private static String generateByteHash(String id)
  {
    try {
      final MessageDigest messageDigest = MessageDigest.getInstance("MD5");
      messageDigest.reset();
      messageDigest.update(id.getBytes(Charset.forName("UTF8")));
      final byte[] resultsByte = messageDigest.digest();
      String hash = new String(Hex.encodeHex(resultsByte));

      final int length = 8;
View Full Code Here


        } catch (Exception e) {
            mLogger.error("Exception: " + e);
            return password;
        }
       
        md.reset();
       
        // call the update method one or more times
        // (useful when you don't know the size of your data, eg. stream)
        md.update(unencodedPassword);
       
View Full Code Here

     * @return An hexadecimal Hash
     */
    public String hexMD5(String value) {
        try {
            MessageDigest messageDigest = MessageDigest.getInstance(Hash.MD5.toString());
            messageDigest.reset();
            messageDigest.update(value.getBytes(UTF_8));
            byte[] digest = messageDigest.digest();
            return String.valueOf(Hex.encodeHex(digest));
        } catch (Exception ex) {
            throw new RuntimeException(ex);
View Full Code Here

            if (saltPhrase != null) {
                md.update(saltPhrase.getBytes());
                byte[] salt = md.digest();

                md.reset();
                md.update(password.getBytes());
                md.update(salt);
            } else {
                md.update(password.getBytes());
            }
View Full Code Here

            alg = MessageDigest.getInstance("SHA-1");
        } catch (NoSuchAlgorithmException ex) {
            // this should never happen
            throw new MathInternalError(ex);
        }
        alg.reset();

        // Compute number of iterations required (40 bytes each)
        int numIter = (len / 40) + 1;

        StringBuilder outBuffer = new StringBuilder();
View Full Code Here

        try {
            md = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException("Unable to locate MD5 hash algorithm", e);
        }
        md.reset();
        //byte[] thedigest = md.digest(bytesOfScript);
        md.update(bytesOfScript);
        byte[] messageDigest = md.digest();
        StringBuffer hexString = new StringBuffer();
        for (int i = 0; i < messageDigest.length; i++) {
View Full Code Here

   
    // produce encrypted message
    Cipher cipher = encrypt.getSymEncodingCipher();
   
    MessageDigest digest = MessageDigest.getInstance("MD5");
    digest.reset();
    digest.update(encrypt.getDesKey().getEncoded());
      
    String symVersion = new String(digest.digest(), "UTF-8");
   
    encrypt.keyServer = false;
View Full Code Here

    peer.setObserver(peerObserver);
    peer.keyServer = false;
   
   
    MessageDigest digest = MessageDigest.getInstance("MD5");
    digest.reset();
    digest.update(server.getDesKey().getEncoded());
      
    String symVersion = new String(digest.digest(), "UTF-8");
   
    // encrypt and send an initial message to peer
View Full Code Here

    Cipher cipher = encrypt2.getSymEncodingCipher();
    byte[] encodedBytes = cipher.doFinal(messageText.getBytes());
    assertNotSame(new String(encodedBytes),messageText);
   
    MessageDigest digest = MessageDigest.getInstance("MD5");
    digest.reset();
    digest.update(encrypt.getDesKey().getEncoded());
      
    String symVersion = new String(digest.digest(), "UTF-8");
   
    Message msg = new Message(null,null,encodedBytes);
View Full Code Here

    Cipher cipher = encrypt2.getSymEncodingCipher();
    byte[] encodedBytes = cipher.doFinal(messageText.getBytes());
    assertNotSame(new String(encodedBytes),messageText);
   
    MessageDigest digest = MessageDigest.getInstance("MD5");
    digest.reset();
    digest.update(encrypt2.getDesKey().getEncoded());
      
    String symVersion = new String(digest.digest());
   
    Message msg = new Message(null,null,encodedBytes);
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.