Encrypt the password with the salt
@param salt
@param password
198135
function encrypt(salt, password) {
    var hash = crypto.createHash('sha256').update(salt + password).digest('base64');
    return salt + hash;
}
1216976
function (user, password, salt) {
  var inner = md5(password + user)
  var outer = md5(Buffer.concat([Buffer.from(inner), salt]))
  return 'md5' + outer
}
331788
def encrypt(data, opts={})
      salt = generate_salt(opts[:salt])
      setup_cipher(:encrypt, salt)
      e = cipher.update(data) + cipher.final
      e = "Salted__#{salt}#{e}" #OpenSSL compatible
      opts[:binary] ? e : Base64.encode64(e)
    end
871360
public static String computePasswordHash(final String password, final String salt) {
    return computePasswordHash(password, stringToSalt(salt));
  }
513053
def apache_md5crypt(password, salt, magic='$apr1$'):
    
    password = password.encode('utf-8')
    salt = salt.encode('utf-8')
    magic = magic.encode('utf-8')

    m = md5()
    m.update(password + magic + salt)

    mixin = md5(password + salt + password).digest()
    for i in range(0, len(password)):
        m.update(mixin[i % 16])

    i = len(password)
    while i:
        if i & 1:
            m.update('\x00')
        else:
            m.update(password[0])
        i >>= 1

    final = m.digest()

    for i in range(1000):
        m2 = md5()
        if i & 1:
            m2.update(password)
        else:
            m2.update(final)

        if i % 3:
            m2.update(salt)

        if i % 7:
            m2.update(password)

        if i & 1:
            m2.update(final)
        else:
            m2.update(password)

        final = m2.digest()

    itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'

    rearranged = ''
    seq = ((0, 6, 12), (1, 7, 13), (2, 8, 14), (3, 9, 15), (4, 10, 5))
    for a, b, c in seq:
        v = ord(final[a]) << 16 | ord(final[b]) << 8 | ord(final[c])
        for i in range(4):
            rearranged += itoa64[v & 0x3f]
            v >>= 6

    v = ord(final[11])
    for i in range(2):
        rearranged += itoa64[v & 0x3f]
        v >>= 6

    return magic + salt + '$' + rearranged
755032
def sha2_rsa_encrypt(password, salt, public_key):
    
    if not _have_cryptography:
        raise RuntimeError("'cryptography' package is required for sha256_password or caching_sha2_password auth methods")
    message = _xor_password(password + b'\0', salt)
    rsa_key = serialization.load_pem_public_key(public_key, default_backend())
    return rsa_key.encrypt(
        message,
        padding.OAEP(
            mgf=padding.MGF1(algorithm=hashes.SHA1()),
            algorithm=hashes.SHA1(),
            label=None,
        ),
    )
699099
function(password) {
				if (!password || !this.salt) return '';
				var salt = new Buffer(this.salt, 'base64');
				return crypto.pbkdf2Sync(password, salt, 10000, 64).toString('base64');
			}
353163
def set_password(self, password, encryptAlgo='MD5'):
		
		if not password:
			self.info['encryptionAlgorithmID'] = None
			self.info['keyHashAlgorithm'] = None
			return

		self.password = gntp.shim.b(password)
		self.encryptAlgo = encryptAlgo.upper()

		if not self.encryptAlgo in self.hash_algo:
			raise errors.UnsupportedError('INVALID HASH "%s"' % self.encryptAlgo)

		hashfunction = self.hash_algo.get(self.encryptAlgo)

		password = password.encode('utf8')
		seed = time.ctime().encode('utf8')
		salt = hashfunction(seed).hexdigest()
		saltHash = hashfunction(seed).digest()
		keyBasis = password + saltHash
		key = hashfunction(keyBasis).digest()
		keyHash = hashfunction(key).hexdigest()

		self.info['keyHashAlgorithmID'] = self.encryptAlgo
		self.info['keyHash'] = keyHash.upper()
		self.info['salt'] = salt.upper()
1271039
def encrypt(passwd):
    
    m = sha1()
    salt = hexlify(os.urandom(salt_len))
    m.update(unicode2bytes(passwd) + salt)
    crypted = bytes2unicode(salt) + m.hexdigest()
    return crypted
455843
public static String getHash(final String password, final String salt) {

		if (StringUtils.isEmpty(salt)) {

			return getSimpleHash(password);

		}

		return DigestUtils.sha512Hex(DigestUtils.sha512Hex(password).concat(salt));

	}
1307136
def encrypt_password(password, salt, hash)
      case hash.to_s
      when 'sha256'
        Digest::SHA256.hexdigest("#{password}-#{salt}")
      else
        raise 'Unsupported hash algorithm'
      end
    end
1175143
private Cipher createCipher( final byte [] pwdAsBytes, byte [] salt, final int mode )
    throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException
    {
        _digester.reset();
        
        byte[] keyAndIv = new byte[ SPICE_SIZE * 2 ];
        
        if( salt == null || salt.length == 0 )
        {
            // Unsalted!  Bad idea!
            salt = null;
        }
        
        byte[] result;
        
        int currentPos = 0;
        
        while (currentPos < keyAndIv.length)
        {
            _digester.update(pwdAsBytes);
            
            if (salt != null)
            {
                // First 8 bytes of salt ONLY!  That wasn't obvious to me
                // when using AES encrypted private keys in "Traditional
                // SSLeay Format".
                //
                // Example:
                // DEK-Info: AES-128-CBC,8DA91D5A71988E3D4431D9C2C009F249
                //
                // Only the first 8 bytes are salt, but the whole thing is
                // re-used again later as the IV.  MUCH gnashing of teeth!
                _digester.update( salt, 0, 8 );
            }
            result = _digester.digest();
            
            int stillNeed = keyAndIv.length - currentPos;
            
            // Digest gave us more than we need.  Let's truncate it.
            if (result.length > stillNeed)
            {
                byte[] b = new byte[stillNeed];
                
                System.arraycopy(result, 0, b, 0, b.length);
                
                result = b;
            }
            
            System.arraycopy(result, 0, keyAndIv, currentPos, result.length);
            
            currentPos += result.length;
            
            if (currentPos < keyAndIv.length)
            {
                // Next round starts with a hash of the hash.
                _digester.reset();
                _digester.update(result);
            }
        }

        byte[] key = new byte[ SPICE_SIZE ];
        
        byte[] iv = new byte[ SPICE_SIZE ];
        
        System.arraycopy(keyAndIv, 0, key, 0, key.length);
        
        System.arraycopy(keyAndIv, key.length, iv, 0, iv.length);

        Cipher cipher = Cipher.getInstance( CIPHER_ALG );

        cipher.init( mode, new SecretKeySpec( key, KEY_ALG ), new IvParameterSpec( iv ) );
        
        return cipher;
    }
1072368
public function encrypt($password, $data)
    {
        $salt = substr(md5(mt_rand(), true), 8);
        $key = md5($password . $salt, true);
        $iv  = md5($key . $password . $salt, true);
        $ct = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, $iv);
        return base64_encode('Salted__' . $salt . $ct);
    }
754705
private String hashPassword(String password)
	{
		return BCrypt.hash(password.toCharArray(), BCrypt.DEFAULT_COST);
	}
581376
public static function password_hash($password, $salt)
    {
        $app_auth_pepper = Config::get('security.auth_pepper', '');
        return sha1($password . $salt . $app_auth_pepper);
    }
165132
public void decrypt(byte[] password) throws GeneralSecurityException {
        if (!isEncrypted()) {
            return;
        }

        byte[] enc = Base64.decode(this.encodedKey);

        SecretKeySpec key = getSecretKey(password, this.initializationVector.getIV());

        Cipher cipher = getCipher();
        cipher.init(Cipher.DECRYPT_MODE, key, this.initializationVector);
        enc = cipher.doFinal(enc);

        this.intKey = getKey(this.keyAlg, enc);
        this.keyData = enc;
        this.isEncrypted = false;
        this.encodedKey = null;
    }
13773
function hash_password(plain_text, salt, callback) {
  // Get the crypto library.
  const crypto = require("crypto")

  // These should be a *slow* as possible, higher = slower.
  // Slow it down until you tweak a bounce change.
  const password_iterations = process.env.PW_GEN_PW_ITERS || 4096

  // Password length and algorithm.
  const password_length = process.env.PW_GEN_PW_LENGTH || 512
  const password_algorithm = process.env.PW_GEN_PW_ALG || "sha256"

  // Create a hash, we're going to encrypt the password.
  // I wish Node had native support for good KDF functions
  // like bcrypt or scrypt but PBKDF2 is good for now.
  crypto.pbkdf2(plain_text, salt, password_iterations, password_length, password_algorithm, (err, key) => {
    // Move on.
    callback(key.toString("hex"), salt)
  })
}