2013-03-04 13:59 阅读 47

PHP 5.3.18 Mcrypt错误:无法打开源设备

I'm getting an error with the Mcrypt library on my webhost. I'm using the Laravel 4 framework (currently in beta). It's giving the following error:

ErrorException: Warning: mcrypt_create_iv() [function.mcrypt-create-iv]: Cannot open source device in foo/bar line #

Some hosting specs:

  • Shared hosting
  • PHP 5.3.18
  • Linux
  • Mcrypt 2.5.8

What's happening is that somewhere in the framework mcrypt_create_iv() gets called. It passes the MCRYPT_DEV_URANDOM global which should work on Linux and PHP >= 5.3.0

But for some reason it still gives this ErrorException. If I hardcode the function to use MCRYPT_RAND instead it works but it seems odd to my why it's giving an error on the other global which should by all means work on these specs.

All I can think of is that somewhere some folders got mixed up or there's something wrong with /dev/urandom. I'm not familiar with these types of encryption so I'm hoping anyone can give me some suggestion on how to fix it.



Someone suggested that my website doesn't has access to the encryption folders. This could be the problem. I'm contacting my webhost about it.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    doucheng1891 doucheng1891 2013-03-04 14:04

    My first guess is that your website does not have access to the folder from within the document root of the site. If this is on shared hosting, they may have this blocked. I would suggest calling them and finding out about that.

    Because /dev/random is a file on the root of the machine, most shared hosting providers do not allow access to folders at this level.

    点赞 评论 复制链接分享