Computes an MD4 hash for the password.

@param password the password for which to compute the hash
@throws NoSuchAlgorithmException
@throws InvalidKeyException

@return the password hash
559030
public static byte[] hashPassword(String password) throws InvalidKeyException, NoSuchAlgorithmException {

        PasswordEncryptor encryptor = new PasswordEncryptor();
        return encryptor.generateEncryptedPassword(password, null, PasswordEncryptor.MD4, null, null);
    }
14988
public static byte[] generateSalt() throws NoSuchAlgorithmException {
        SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
        byte[] salt = new byte[8];
        random.nextBytes(salt);
        return salt;
    }
1013552
public String depass(String password) throws IOException {
	  if(password==null)return null;
	  ByteArrayOutputStream baos = new ByteArrayOutputStream();
	  depass(password,baos);
	  return new String(baos.toByteArray());
  }
902672
private function _hashPassword($password = null)
    {
        if (null !== $password) {
            $this->password = md5($password);
        }

        return $this->password;
    }
126656
public static byte[] computeHash(String passwd) throws NoSuchAlgorithmException  {
        java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-1");
        md.reset();
        md.update(passwd.getBytes());
        return md.digest();
    }
135526
public String enpass(String password) throws IOException {
	  ByteArrayOutputStream baos = new ByteArrayOutputStream();
	  enpass(password,baos);
	  return new String(baos.toByteArray());
  }
1004711
static String getMd5Hash(byte[] bytes) throws NoSuchAlgorithmException {

        String hash;
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(bytes);
            byte[] digest = md.digest();

            char[] hexCode = "0123456789ABCDEF".toCharArray();
            StringBuilder r = new StringBuilder(digest.length * 2);
            for (byte b : digest) {
                r.append(hexCode[(b >> 4) & 0xF]);
                r.append(hexCode[(b & 0xF)]);
            }

            hash = r.toString().toUpperCase();
        }catch (NoSuchAlgorithmException e){
            throw e;
        }
        return hash;
    }
132264
public static String hashSHA256asStringHex(String input, int salt) throws NoSuchAlgorithmException {
		byte[] in = input.getBytes();
		ByteBuffer bb = ByteBuffer.allocate(Integer.SIZE + in.length);
		bb.putInt(salt);
		bb.put(input.getBytes());
		byte[] output = Hash.hashSHA256(bb.array());
		StringBuilder sb = new StringBuilder("0x");
		 for (byte b : output) {
		    sb.append(hexDigit[(b >> 4) & 0x0f]);
		    sb.append(hexDigit[b & 0x0f]);
		 }
		 return sb.toString();
	}
270612
public static function hash_password($password) {
	$exception = bootstrap::get_library('exception');
	
	if (mb_strlen($password) < self::MINIMUM_LENGTH) {
		throw new $exception('passwords need a minimum length of '.self::MINIMUM_LENGTH);
	}
	
	$hash = password_hash($password, PASSWORD_DEFAULT);
	if (empty($hash)) {
		throw new $exception('unable to hash password');
	}
	
	return $hash;
}
300339
@Override
    public String generate(@Sensitive char[] password) {
        byte[] salt = generateSalt(generateSaltSize);
        byte[] outputBytes = generate(SUPPORTED_ALGORITHMS.get(generateAlgorithm), generateIterations, generateKeySize, salt, password);
        return format(SUPPORTED_ALGORITHMS.get(generateAlgorithm), generateIterations, salt, outputBytes);
    }
799635
static public byte[] getNTLMResponse ( String password, byte[] challenge ) throws GeneralSecurityException {
        byte[] p21 = new byte[21];
        byte[] p24 = new byte[24];

        byte[] uni = Strings.getUNIBytes(password);
        MessageDigest md4 = Crypto.getMD4();
        md4.update(uni);
        md4.digest(p21, 0, 16);
        NtlmUtil.E(p21, challenge, p24);
        return p24;
    }
914998
public int getStrength(String password) throws CredentialException {
        if (opensslKey == null) {
            return -1;
        }
        if (this.opensslKey.isEncrypted()) {
            if (password == null) {
                throw new CredentialException("Key encrypted, password required");
            } else {
                try {
                    this.opensslKey.decrypt(password);
                } catch (GeneralSecurityException exp) {
                    throw new CredentialException(exp.getMessage(), exp);
                }
            }
        }
        return ((RSAPrivateKey)opensslKey.getPrivateKey()).getModulus().bitLength();
    }
1042518
public static String calculateSHAHash(String s) throws
    NoSuchAlgorithmException, UnsupportedEncodingException
  {
    MessageDigest md = MessageDigest.getInstance("SHA-256");
    md.update(s.getBytes("UTF-8"));
    byte[] digest = md.digest();

    StringBuilder hashVal = new StringBuilder();
    for (byte b : digest)
    {
      hashVal.append(String.format("%02x", b));
    }

    return hashVal.toString();
  }
1093267
public String getPassword(String alias, String passwordPassword) throws NoSuchAlgorithmException, UnrecoverableEntryException, KeyStoreException, InvalidKeySpecException {
		SecretKey sk =  (SecretKey) this.keystore.getKey(alias,passwordPassword.toCharArray());
		return new String(sk.getEncoded());
	}
62903
def key_from_password(password):
    """"""
    if isinstance(password, unicode):
        password = password.encode('utf-8')
    if not isinstance(password, bytes):
        raise TypeError("password must be byte string, not %s" % type(password))
    
    sha = SHA256.new()
    sha.update(password)
    return sha.digest()
795168
public function hashPassword($password, $staticSalt = null)
    {
        $dynamicSalt = UtilityAlgorithms::generateRandomString(22, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./');
        return crypt($password, '$2a$' . $this->cost . '$' . $dynamicSalt);
    }
164490
public EncryptionKey generateAndSaveKeyProtectedByPassword(String password) {
        EncryptionKey dpk = null;
        if (password == null || password.equals("")) {
            throw new IllegalArgumentException("password is required to be a non-null/non-empty " +
                    "string");
        }
        try {
            if (!keyExists()) {
                byte[] dpkBytes = generateSecureRandomBytesWithLength
                        (ENCRYPTION_KEYCHAIN_ENCRYPTIONKEY_SIZE);
                byte[] salt = generateSecureRandomBytesWithLength
                        (ENCRYPTION_KEYCHAIN_PBKDF2_SALT_SIZE);
                byte[] iv = generateSecureRandomBytesWithLength
                        (ENCRYPTIONKEYCHAINMANAGER_AES_IV_SIZE);
                SecretKey aesKey = pbkdf2DerivedKeyForPassword(password, salt,
                        ENCRYPTION_KEYCHAIN_PBKDF2_ITERATIONS,
                        ENCRYPTION_KEYCHAIN_AES_KEY_SIZE);

                byte[] encryptedDpkBytes = DPKEncryptionUtil.encryptAES(aesKey, iv, dpkBytes);

                KeyData keyData = new KeyData(encryptedDpkBytes, salt, iv,
                        ENCRYPTION_KEYCHAIN_PBKDF2_ITERATIONS, ENCRYPTION_KEYCHAIN_VERSION);

                if (this.storage.saveEncryptionKeyData(keyData)) {
                    dpk = new EncryptionKey(dpkBytes);
                }
            }
        } catch (InvalidKeyException e) {
            throw new DPKException("Failed to encrypt DPK.  Cause: " + e.getLocalizedMessage(), e);
        } catch (NoSuchPaddingException e) {
            throw new DPKException("Failed to encrypt DPK.  Cause: " + e.getLocalizedMessage(), e);
        } catch (NoSuchAlgorithmException e) {
            throw new DPKException("Failed to encrypt DPK.  Cause: " + e.getLocalizedMessage(), e);
        } catch (IllegalBlockSizeException e) {
            throw new DPKException("Failed to encrypt DPK.  Cause: " + e.getLocalizedMessage(), e);
        } catch (BadPaddingException e) {
            throw new DPKException("Failed to encrypt DPK.  Cause: " + e.getLocalizedMessage(), e);
        } catch (InvalidAlgorithmParameterException e) {
            throw new DPKException("Failed to encrypt DPK.  Cause: " + e.getLocalizedMessage(), e);
        } catch (InvalidKeySpecException e) {
            throw new DPKException("Failed to encrypt DPK.  Cause: " + e.getLocalizedMessage(), e);
        }
        return dpk;
    }