在Laravel中使用SHA 1哈希

问题描述 投票:-2回答:1

我想在laravel中使用sha1散列一些字符串。但无论字符串是什么,它们都返回相同的哈希值。拜托,我需要知道为什么会这样,或者我做错了什么。见下面我的代码:

$lice = $serial->sname.$serial->company.$serial->effDate.$serial->ltype;
        //$serial->sname is MTS;
        //$serial->company is Godowns Technology;
        //$serial->effDate is 2017-01-24;
        //$serial->ltype is Trial

        $lice2= sha1($lice);
        $lice3 = chunk_split($lice2,5,'-');
        $lice4 =strtoupper($lice3);
  based on the information above, the $lice4 is always return: 
DA39A-3EE5E-6B4B0-D3255-BFEF9-56018-90AFD-80709

拜托,我需要帮助

php laravel cryptographic-hash-function
1个回答
0
投票

所有,我做的是确保我的变量从表单中获取并且它们是正确的目标。因此,一旦完成,我可以连接并获得正确的哈希值。

 $lice = $request->sname.$request->company.$request->effDate;
        //$lice = $serial->sname;
        $lice2= sha1($lice);
        $lice3 = chunk_split($lice2,5,'-');
        $lice4 =strtoupper($lice3);

       Serial::create([
        'sname' => $request->sname,
        'company' => $request->company,
        'effDate' => $request->effDate,
        'ltype' => $request->ltype
        ]);
© www.soinside.com 2019 - 2024. All rights reserved.