Encrypt passwords

@param password
@return String
@throws AuthenticationException
338691
public static String encrypt(final String password) throws AuthenticationException {
        String hashValue;
        try {
            final MessageDigest msgDigest = MessageDigest.getInstance("SHA");
            msgDigest.update(password.getBytes("UTF-8"));
            final byte rawByte[] = msgDigest.digest();
            hashValue = new String(Base64.encodeBase64(rawByte));

        } catch (Exception e) {
            LOG.error("Encryption failed.");
            throw new AuthenticationException("Error occurred during password encryption", e);
        }

        return hashValue;
    }
237783
public static function passwordEncrypt (string $password=NULL) : string
	{
		$hashFormat 	= "$2y$10$";
		// Tells php to use blowfish with a cost of 10
		$saltLength 	= 22;
		// Blowfish Salts should be 22-characters or more
		$salt 			= static::generateSalt($saltLength);
		$formatAndSalt 	= $hashFormat.$salt;
		return crypt($password, $formatAndSalt);
	}
789500
protected function encryptPassword()
    {
        // reset salt so that it gets regenerated - this will invalidate any persistent login cookies
        // or other information encrypted with this Member's settings (see self::encryptWithUserSettings)
        $this->Salt = '';

        // Password was changed: encrypt the password according the settings
        $encryption_details = Security::encrypt_password(
            $this->Password,
            $this->Salt,
            $this->isChanged('PasswordEncryption') ? $this->PasswordEncryption : null,
            $this
        );

        // Overwrite the Password property with the hashed value
        $this->Password = $encryption_details['password'];
        $this->Salt = $encryption_details['salt'];
        $this->PasswordEncryption = $encryption_details['algorithm'];

        // If we haven't manually set a password expiry
        if (!$this->isChanged('PasswordExpiry')) {
            // then set it for us
            if (static::config()->get('password_expiry_days')) {
                $this->PasswordExpiry = date('Y-m-d', time() + 86400 * static::config()->get('password_expiry_days'));
            } else {
                $this->PasswordExpiry = null;
            }
        }

        return $this;
    }
1322269
protected String encodePassword(String password)
   {
      StringBuilder result = new StringBuilder();
      if (password != null)
      {
         for (int i = 0; i < password.length(); i++)
         {
            int c = password.charAt(i);
            c ^= 0xdfaa;
            result.append(Integer.toHexString(c));
         }
      }
      return result.toString();
   }
1149071
public String encriptPassword(String password)
    {
        String newpassword = null;
        byte[] defaultBytes = password.getBytes();
        try
        {
            MessageDigest algorithm = MessageDigest.getInstance("MD5");
            algorithm.reset();
            algorithm.update(defaultBytes);
            byte messageDigest[] = algorithm.digest();

            StringBuffer hexString = new StringBuffer();
            for (int i = 0; i < messageDigest.length; i++)
            {
                hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
            }
            newpassword = hexString.toString();
        }
        catch (NoSuchAlgorithmException e)
        {
            log.error("Error while encripting password {}, caused by : .", password, e);
            throw new PersistenceException(e);
        }
        return newpassword;
    }
580295
public String readPassword(String password) {
    if (password == null || encryptors.size() < 1) {
      return password;
    }
    Matcher matcher = PASSWORD_PATTERN.matcher(password);
    if (matcher.find()) {
      return this.decryptPassword(matcher.group(1));
    }
    return password;
  }
902672
private function _hashPassword($password = null)
    {
        if (null !== $password) {
            $this->password = md5($password);
        }

        return $this->password;
    }
282347
public static String decodePassword(@Sensitive String password) {
        String decodedPassword = null;
        // first try to decode
        if (password == null || password.isEmpty())
            return password;

        try {
            decodedPassword = PasswordUtil.decode(password);

            if (decodedPassword != null && !WSKeyStore.defaultKeyStoreWarningIssued && decodedPassword.equals(Constants.DEFAULT_KEYSTORE_PASSWORD)) {
                Tr.warning(tc, "ssl.default.password.in.use.CWPKI0041W");
                defaultKeyStoreWarningIssued = true;
            }
        } catch (InvalidPasswordDecodingException e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "Password was not decoded.");
            decodedPassword = password;
            // password is not encoded
        } catch (Exception e) {
            // password is encoded, but could not be decoded
            FFDCFilter.processException(e, WSKeyStore.class.getName(), "decodePassword");
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "Exception decoding KeyStore password; " + e);
        }
        return decodedPassword;
    }
473593
public function createPasswordHash($password)
    {
        try {
            return $this->driverInstance->createPasswordHash($password);
        } catch (\Exception $e) {
            throw new CryptException($e->getMessage());
        }
    }
309172
public function setPassword($password)
    {
        $this->password    = $password;
        $encryptedPassword = $this->getEncryptedPassword($password, $this->getSecret(), $this->getRequestAuthenticator());

        $this->setAttribute(2, $encryptedPassword);

        return $this;
    }
1145069
protected function encodePassword($password)
    {
        $passwordSalted = $this->saltPassword($password);
        $passwordEncoded = password_hash($passwordSalted, PASSWORD_DEFAULT);
        
        return $passwordEncoded;
    }
1235835
def encode_password(password)
    i = 0
    chars = password.split(//)
    count = chars.size

    chars.collect! do |char|
      i += 1
      char     = char.ord << i
      low_15   = char & 0x7fff
      high_15  = char & 0x7fff << 15
      high_15  = high_15 >> 15
      char     = low_15 | high_15
    end

    encoded_password  = 0x0000
    chars.each { |c| encoded_password ^= c }
    encoded_password ^= count
    encoded_password ^= 0xCE4B
  end
989179
public static String encrypt(String salt, String password, String plainText) {
        SecretKey secret = getKey(salt, password);
        return encryptBouncyCastle(secret, plainText);
    }
376749
public function auth($password)
    {
        $response = $this->__call('auth', [$password]);
        $this->setPassword($password);

        return $response;
    }
620127
public void encrypt(final String userName, final String password) {
        encrypt(userName, password.getBytes(Charsets.UTF_8), MessageEncryption.NONE);
    }
516224
public function authenticate(string $credential, string $password = null): ?UserInterface
    {
        $user = $this->users->read($credential);

        if ($user) {
            if ($password && !$this->verifyPassword($user, $password)) {
                return null;
            }

            return ($this->userFactory)(
                $this->users->getIdentifier(),
                $this->getRoles($credential),
                $this->getDetails($user)
            );
        }

        return null;
    }
950280
public void setPassword(String password) {
        for (Authentication auth : authentications.values()) {
            if (auth instanceof HttpBasicAuth) {
                ((HttpBasicAuth) auth).setPassword(password);
                return;
            }
        }
        throw new RuntimeException("No HTTP basic authentication configured!");
    }