每次我尝试运行 m_decrypt 时,都会抛出以下错误:
Warning: mcrypt_get_key_size(): Module initialization failed in /var/www/milo/system/encryption/common.php on line 51 Warning: mcrypt_get_block_size(): Module initialization failed in /var/www/milo/system/encryption/common.php on line 54 Warning: mcrypt_decrypt(): Module initialization failed in /var/www/milo/system/encryption/common.php on line 55
下面是驱动这一切的代码:
class encrpt
{
protected $data;
protected $key = "JUST A KEY";
protected $cipher = "MCRYPT_SERPENT_256";
protected $mode = "MCRYPT_MODE_CBC";
public function m_encrypt($data)
{
return (string)
base64_encode(
mcrypt_encrypt(
$this->cipher,
substr(md5($this->key),0,mcrypt_get_key_size($this->cipher, $this->mode)),
$data,
$this->mode,
substr(md5($this->key),0,mcrypt_get_block_size($this->cipher, $this->mode))
)
);
}
public function m_decrypt($data)
{
return (string)
mcrypt_decrypt(
$this->cipher,
substr(md5($this->key),0,mcrypt_get_key_size($this->cipher, $this->mode)),
base64_decode($data),
$this->mode,
substr(md5($this->key),0,mcrypt_get_block_size($this->cipher, $this->mode))
);
}
}
我不知道我错过了什么。我的 php-mcrypt 模块是否损坏或缺少依赖项?我在 PHP 5.3 上运行
最佳答案
好的解决了。我输入的常量是错误的。我这样更改了类(class)的变量:
protected $cipher = "rijndael-256";
protected $mode = "cbc";
希望这能帮助人们在以后的道路上不再胡思乱想!!
关于PHP MCRYPT 不断抛出 Module initialization failed Warning,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14005669/
我早就知道Ruby中的“常量”(即大写的变量名)不是真正常量。与其他编程语言一样,对对象的引用是唯一存储在变量/常量中的东西。(侧边栏:Ruby确实具有“卡住”引用对象不被修改的功能,据我所知,许多其他语言都没有提供这种功能。)所以这是我的问题:当您将一个值重新分配给常量时,您会收到如下警告:>>FOO='bar'=>"bar">>FOO='baz'(irb):2:warning:alreadyinitializedconstantFOO=>"baz"有没有办法强制Ruby抛出异常而不是打印警告?很难弄清楚为什么有时会发生重新分配。 最佳答案
在尝试实现应用auto_orient的过程之后!对于我的图片,我收到此错误:ArgumentError(noimagesinthisimagelist):app/uploaders/image_uploader.rb:36:in`fix_exif_rotation'app/controllers/posts_controller.rb:12:in`create'Carrierwave在没有进程的情况下工作正常,但在添加进程后尝试上传图像时抛出错误。流程如下:process:fix_exif_rotationdeffix_exif_rotationmanipulate!do|image|
我在RubyonRails4.1.4上有一个项目,使用来自git://github.com/activeadmin/activeadmin的activeadmin1.0.0.pre,pg0.17.1,PostgreSQL9.3在项目中我有这些模型:类用户has_one:账户类账户属于:用户有很多:project_accountshas_many:项目,:through=>:project_accounts类项目#该项目有一个bool属性'archive'has_many:project_accounts类ProjectAccount属于:帐户属于:项目我有一个任务是在索引页面上实现一个
我正在尝试编写这样的代码:assert_throws(:ExtractionFailed){unit.extract_from('5x2005')}ExtractionFailed是Exception的一个简单子(monad)类,在test/unit下,我试图断言它在我调用unit.extract_from(...坏数据...)我已经将ExtractionFailed移动到SemanticText模块中,所以现在test/unit说:expectedtobethrownbutwasthrown.我尝试编写assert_throws(:SemanticText::ExtractionFa
我无法向自己解释的简单代码:putsaifa=1这导致warning:found=inconditional,shouldbe==NameError:undefinedlocalvariableormethod'a'formain:Object不过,现在检查a我们可以看到,它已被定义:a#=>1尽管抛出异常,为什么a仍被分配给1?来自docs:Theconfusioncomesfromtheout-of-orderexecutionoftheexpression.Firstthelocalvariableisassigned-tothenyouattempttocallanonexis
我们使用Ruby2.1.2、Rails3.2.19和JQuery1.11,未使用Assets管道(因此未使用JQuery-ujs,但明确使用相关的rails.js)。对于大多数用户来说,JQuery和其他相关的常用插件都是从GoogleCDN中提取的(包括jquery.form3.50)。受影响的网络服务器是Ubuntu14.04、Nginx1.6和Passenger4.x。对于我们生产服务器上大约10%的用户(负载似乎无关紧要),我们得到了这样的堆栈转储,主要针对一个URL,但也有其他URL:/gems/rack-1.4.5/lib/rack/multipart/parser.rb:
你好,我是铁路新手。我正在关注MichaelHartl的railstutorial.org。我卡在了第4章的list4.5中:当我点击$bundleexecraketest时,它显示的结果与按照教程应该显示的结果不同。注意:我使用的是Ubuntu15.10作为平台。当我点击$bundleexecraketest时的结果/home/shyambhimani/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/minitest-reporters-1.0.5/lib/minitest/minitest_reporter_plugin.rb:8:in
场景#1:在下面的示例中,putsPost::User.foo行打印foo。换句话说,Post::User返回一个全局的User常量。classUserdefself.foo"foo"endendclassPostputsPost::User.fooend#=>warning:toplevelconstantUserreferencedbyPost::User#=>foo场景#2:第二个示例会引发错误,因为未找到常量。moduleUserdefself.foo"foo"endendmodulePostputsPost::User.fooend#=>uninitializedconsta
我正在将Rails4.1.8应用程序(也使用rails-api~>0.3.1)升级到4.2.0.rc2,并希望保留respond_with功能。我已将responders添加到Gemfile,但是当我bin/rakespec时,我得到:/Users/sloveless/.gem/ruby/2.1.0/gems/actionpack-4.2.0.rc2/lib/action_controller/metal/mime_responds.rb:10:in`respond_to':Thecontroller-level`respond_to'featurehasbeenextractedto
我正在学习RubyKoans中的练习在about_proxy_object_project.rb中有这段代码:classProxydefinitialize(target_object)@object=target_objectend#Thismethodwasaddedbymedefmethod_missing(method_name,*args,&block)@object.sendmethod_nameendend这样调用:deftest_tv_methods_still_perform_their_functiontv=Proxy.new(Television.new)#Tel