Frontend\Modules\Profiles\Engine\Model::getEncryptedString PHP Method

getEncryptedString() public static method

Get an encrypted string.
public static getEncryptedString ( string $string, string $salt ) : string
$string string String to encrypt.
$salt string Salt to add to the string.
return string
    public static function getEncryptedString($string, $salt)
    {
        return md5(sha1(md5((string) $string)) . sha1(md5((string) $salt)));
    }

Usage Example

Example #1
0
 /**
  * Update profile password and salt.
  *
  * @param int    $profileId Profile id for which we are changing the password.
  * @param string $password  New password.
  */
 public static function updatePassword($profileId, $password)
 {
     $profileId = (int) $profileId;
     $password = (string) $password;
     // get new salt
     $salt = FrontendProfilesModel::getRandomString();
     // encrypt password
     $encryptedPassword = FrontendProfilesModel::getEncryptedString($password, $salt);
     // update salt
     FrontendProfilesModel::setSetting($profileId, 'salt', $salt);
     // update password
     FrontendProfilesModel::update($profileId, array('password' => $encryptedPassword));
 }
All Usage Examples Of Frontend\Modules\Profiles\Engine\Model::getEncryptedString