简体   繁体   English

Laravel 4.2到5.0更新后,Crypt :: decript函数停止工作

[英]The Crypt::decript function stopped working after the Laravel 4.2 to 5.0 update

After the update of L4.2 to L5 the function Crypt::decrypt doesn't work for the hashes generated on L4.2, however my APP_KEY still the same. 在将L4.2更新为L5之后,功能Crypt :: decrypt对于L4.2上生成的哈希不起作用,但是我的APP_KEY仍然相同。

DecryptException in Encrypter.php line 147:
MAC is invalid.

My hashes generated after the update does work, but not for the ones before the migration; 更新后生成的哈希有效,但不适用于迁移前的哈希;

It seems to me that your 64 enocded data is being strip down due to column length and I think you are storing something relatively big. 在我看来,您的64个加密数据由于列长而被精简了,我认为您存储的是相对较大的数据。 I just reproduced your error by adding a very large cache value into the database. 我只是通过向数据库添加非常大的缓存值来重现您的错误。 Make the following changes inside your schema, rollback and rerun the migration: 在架构内进行以下更改,回滚并重新运行迁移:

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCacheTable extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('cache', function(Blueprint $table)
        {
            $table->string('key')->unique();
            $table->longText('value');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('cache');
    }

}

The record you pasted previously giving me a NULL and I think it is because it is striped down. 您之前粘贴的记录为我提供了NULL,我认为这是因为它被缩减了。

After migrating the cache table. 迁移后的cache表。 Put the same cache value and read back hopefully you will not get error this time. 放入相同的缓存值,并希望回读,这次您不会出错。 Finger Crossed! 手指交叉!

Source: https://laracasts.com/discuss/channels/general-discussion/daeling-with-decryptexceptioninvalid-data 资料来源: https : //laracasts.com/discuss/channels/general-discussion/daeling-with-decryptexceptioninvalid-data

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM