update ciphers

This commit is contained in:
printempw 2017-01-08 10:48:46 +08:00
parent 4276b56e0c
commit acb4d643f7
7 changed files with 30 additions and 38 deletions

View File

@ -7,9 +7,9 @@ interface EncryptInterface
/**
* Encrypt given string w/ or w/o salt
*
* @param string $raw_passwd
* @param string $value
* @param string $salt
* @return string ecrypted password
* @return string
*/
public function encrypt($raw_passwd, $salt = "");
public function encrypt($value, $salt = "");
}

View File

@ -5,10 +5,10 @@ namespace App\Services\Cipher;
class MD5 implements EncryptInterface
{
/**
* Once MD5 encrypt
* Once MD5 hash
*/
public function encrypt($raw_passwd, $salt = "") {
$encrypt = md5($raw_passwd);
return $encrypt;
public function encrypt($value, $salt = "")
{
return md5($value);
}
}

View File

@ -4,8 +4,11 @@ namespace App\Services\Cipher;
class SALTED2MD5 implements EncryptInterface
{
public function encrypt($raw_passwd, $salt = "") {
$encrypt = md5(md5($raw_passwd).$salt);
return $encrypt;
/**
* MD5 hash with salt
*/
public function encrypt($value, $salt = "")
{
return md5(md5($value).$salt);
}
}

View File

@ -5,13 +5,10 @@ namespace App\Services\Cipher;
class SALTED2SHA256 implements EncryptInterface
{
/**
* Default SHA256 encryption method for Authme
*
* @see http://pastebin.com/1wy9g2HT
* SHA256 hash with salt
*/
public function encrypt($raw_passwd, $salt = "") {
$encrypt = hash('sha256', hash('sha256', $raw_passwd).$salt);
return $encrypt;
public function encrypt($value, $salt = "")
{
return hash('sha256', hash('sha256', $value).$salt);
}
}

View File

@ -5,13 +5,11 @@ namespace App\Services\Cipher;
class SALTED2SHA512 implements EncryptInterface
{
/**
* Default SHA256 encryption method for Authme
*
* @see http://pastebin.com/1wy9g2HT
* SHA512 with salt
*/
public function encrypt($raw_passwd, $salt = "") {
$encrypt = hash('sha512', hash('sha256', $raw_passwd).$salt);
return $encrypt;
public function encrypt($value, $salt = "")
{
return hash('sha512', hash('sha256', $value).$salt);
}
}

View File

@ -5,13 +5,10 @@ namespace App\Services\Cipher;
class SHA256 implements EncryptInterface
{
/**
* Default SHA256 encryption method for Authme
*
* @see http://pastebin.com/1wy9g2HT
* Once SHA256 hash
*/
public function encrypt($raw_passwd, $salt = "") {
$encrypt = hash('sha256', $raw_passwd);
return $encrypt;
public function encrypt($value, $salt = "")
{
return hash('sha256', $value);
}
}

View File

@ -2,16 +2,13 @@
namespace App\Services\Cipher;
class SHA256 implements EncryptInterface
class SHA512 implements EncryptInterface
{
/**
* Default SHA256 encryption method for Authme
*
* @see http://pastebin.com/1wy9g2HT
* Once SHA512 hash
*/
public function encrypt($raw_passwd, $salt = "") {
$encrypt = hash('sha512', $raw_passwd);
return $encrypt;
public function encrypt($value, $salt = "")
{
return hash('sha512', $value);
}
}