<?php namespace Permission\Common; /** * Created by PhpStorm. * User: Administrator * Date: 2017-05-15 * Time: 10:06 * Ref: Application/Permission/Common/Hash.class.php */ class Hash { /** * @param string $algo The algorithm (sha256, sha1, whirlpool, etc) * @param string $data The data to encode * @param string $salt The salt (This should be the same throughout the system probably) * @return string The hashed/salted data ( C(HASH_PASSWORD_KEY) ) */ public static function create($algo, $data, $salt) { $context = hash_init($algo, HASH_HMAC, $salt); hash_update($context, $data); return hash_final($context); } }\Permission\Common\Hash::create('sha1', $pwd, C('HASH_PASSWORD_KEY')),
你放错地方了
Common\Common 目录下专放函数用的。
你那个类可以Common\目录下新建一个目录放例如Common\Common #函数目录
Common\Tool #工具类目录
Common\Tool\Music.class.php
Common\Tool\tt.class.php命名空间
Common\Tool\Music.class.php
#命名空间就是
namespace Common\Tool\Music;
#调用
use Common\Tool\Music;
改为namespace Common\Common\Function\Music斜杠打错了
namespace Permission\Common;
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2017-05-15
* Time: 10:06
* Ref: Application/Permission/Common/Hash.class.php
*/
class Hash {
/**
* @param string $algo The algorithm (sha256, sha1, whirlpool, etc)
* @param string $data The data to encode
* @param string $salt The salt (This should be the same throughout the system probably)
* @return string The hashed/salted data ( C(HASH_PASSWORD_KEY) )
*/
public static function create($algo, $data, $salt) {
$context = hash_init($algo, HASH_HMAC, $salt);
hash_update($context, $data);
return hash_final($context);
}
}\Permission\Common\Hash::create('sha1', $pwd, C('HASH_PASSWORD_KEY')),