mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
删除File类的md5和sha1方法 改为hash方法 支持更多的散列值类型生成
This commit is contained in:
@@ -95,27 +95,15 @@ class File extends SplFileObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文件的md5散列值
|
* 获取文件的哈希散列值
|
||||||
* @return $this
|
* @return $string
|
||||||
*/
|
*/
|
||||||
public function md5()
|
public function hash($type = 'sha1')
|
||||||
{
|
{
|
||||||
if (!isset($this->hash['md5'])) {
|
if (!isset($this->hash[$type])) {
|
||||||
$this->hash['md5'] = md5_file($this->filename);
|
$this->hash[$type] = hash_file($type, $this->filename);
|
||||||
}
|
}
|
||||||
return $this->hash['md5'];
|
return $this->hash[$type];
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取文件的sha1散列值
|
|
||||||
* @return $this
|
|
||||||
*/
|
|
||||||
public function sha1()
|
|
||||||
{
|
|
||||||
if (!isset($this->hash['sha1'])) {
|
|
||||||
$this->hash['sha1'] = sha1_file($this->filename);
|
|
||||||
}
|
|
||||||
return $this->hash['sha1'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user