Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply fixes from StyleCI #31

Merged
merged 1 commit into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/Models/Attributes/Password.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static function encode($password)
*/
public static function ssha($password)
{
return "{SSHA}".static::makeHash($password, 'sha1');
return '{SSHA}'.static::makeHash($password, 'sha1');
}

/**
Expand All @@ -37,7 +37,7 @@ public static function ssha($password)
*/
public static function ssha256($password)
{
return "{SSHA256}".static::makeHash($password, 'hash', 'sha256');
return '{SSHA256}'.static::makeHash($password, 'hash', 'sha256');
}

/**
Expand All @@ -49,7 +49,7 @@ public static function ssha256($password)
*/
public static function ssha384($password)
{
return "{SSHA384}".static::makeHash($password, 'hash', 'sha384');
return '{SSHA384}'.static::makeHash($password, 'hash', 'sha384');
}

/**
Expand All @@ -61,7 +61,7 @@ public static function ssha384($password)
*/
public static function ssha512($password)
{
return "{SSHA512}".static::makeHash($password, 'hash', 'sha512');
return '{SSHA512}'.static::makeHash($password, 'hash', 'sha512');
}

/**
Expand All @@ -73,7 +73,7 @@ public static function ssha512($password)
*/
public static function sha($password)
{
return "{SHA}".static::makeHash($password, 'sha1', $algo = null, $salt = false);
return '{SHA}'.static::makeHash($password, 'sha1', $algo = null, $salt = false);
}

/**
Expand All @@ -85,7 +85,7 @@ public static function sha($password)
*/
public static function sha256($password)
{
return "{SHA256}".static::makeHash($password, 'hash', 'sha256', $salt = false);
return '{SHA256}'.static::makeHash($password, 'hash', 'sha256', $salt = false);
}

/**
Expand All @@ -97,7 +97,7 @@ public static function sha256($password)
*/
public static function sha384($password)
{
return "{SHA384}".static::makeHash($password, 'hash', 'sha384', $salt = false);
return '{SHA384}'.static::makeHash($password, 'hash', 'sha384', $salt = false);
}

/**
Expand All @@ -109,7 +109,7 @@ public static function sha384($password)
*/
public static function sha512($password)
{
return "{SHA512}".static::makeHash($password, 'hash', 'sha512', $salt = false);
return '{SHA512}'.static::makeHash($password, 'hash', 'sha512', $salt = false);
}

/**
Expand All @@ -121,7 +121,7 @@ public static function sha512($password)
*/
public static function smd5($password)
{
return "{SMD5}".static::makeHash($password, 'md5', $algo = null, $salt = true);
return '{SMD5}'.static::makeHash($password, 'md5', $algo = null, $salt = true);
}

/**
Expand All @@ -133,16 +133,16 @@ public static function smd5($password)
*/
public static function md5($password)
{
return "{MD5}".static::makeHash($password, 'md5', $algo = null, $salt = false);
return '{MD5}'.static::makeHash($password, 'md5', $algo = null, $salt = false);
}

/**
* Make a new password hash.
*
* @param string $password The password to make a hash of
* @param string $method The hash function to use
* @param string|null $algo The algorithm to use for hashing
* @param bool $salt Whether a salt is required
* @param string $method The hash function to use
* @param string|null $algo The algorithm to use for hashing
* @param bool $salt Whether a salt is required
*
* @return string
*/
Expand All @@ -154,6 +154,6 @@ protected static function makeHash($password, $method, $algo = null, $salt = tru
// into the method for generating the password hash.
$params = $algo ? [$algo, $password.$salt] : [$password.$salt];

return base64_encode(pack("H*", call_user_func($method, ...$params)) . $salt);
return base64_encode(pack('H*', call_user_func($method, ...$params)).$salt);
}
}
}
2 changes: 1 addition & 1 deletion tests/Models/Attributes/PasswordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function test_ssha384()
);
}

public function test_ssha512()
public function test_ssha512()
{
$this->assertNotEquals(
Password::ssha512('password'),
Expand Down