无法解密/解码密钥

时间:2013-05-28 19:06:34

标签: php codeigniter encryption amazon-ec2 twitter

我的Amazon EC2实例(slightly similar to this question)上的CodeIgniter控制器中似乎没有解密我的Twitter API 1.1的消费者密钥,因为

  • 我在排除故障时遇到unable to authenticate you错误
  • 和我的print_r($settings)语句(见下文)显示了浏览器中消费者秘密的不可兑换字符,尽管我使用此行'consumer_secret' => $this->encrypt->decode($this->config->item('consumer_secret')解密了它。

my_controller.php

$settings = array(
            'oauth_access_token' => $this->config->item('oauth_access_token'),
            'oauth_access_token_secret' => $this->config->item('oauth_access_token_secret'),
            'consumer_key' => $this->config->item('consumer_key'),
            'consumer_secret' => $this->encrypt->decode($this->config->item('consumer_secret'))
        );  
        print_r($settings);

注意:我在CodeIgniter的配置目录中保存了加密的消费者密钥,并在config.php中设置了我的加密密钥。有趣的是,它在WAMP中运行良好,但在Amazon EC2中运行不正常。

如何解决此问题?我应该只将未加密的消费者密钥保存在配置文件中吗?

1 个答案:

答案 0 :(得分:2)

Codeigniter使用一些标准加密库,如果它们不可用则会退回。我不认为mcrypt在默认的Amazon Linux AMI上可用。你可以

a)使用后备;只需重新加密ec2上的consumer_secret并将其放入config

b)安装mcrypt

$ sudo yum install php-mcrypt
$ sudo service httpd restart
相关问题