codeigniter加密/解密函数返回空字符串 [英] codeigniter encryption / decryption function returns empty string

查看:95
本文介绍了codeigniter加密/解密函数返回空字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用codeigniter登录,但无法登录。
然后我尝试从数据库复制密码,并将其传递给dycription-> decode()函数,它返回空字符串。

I am trying to login using codeigniter, but not able to do so. Then i tried to copy password from DB and pass it to dycription->decode() function, and it's returning empty string.

这是代码

var_dump($this->encryption->decode('s0xxxxxxXjrUxxxxxxBTxxxxhc'));

输出为: string(0)

并且此代码还返回空字符串

And this code also returning empty strings

$decoded_password = $this->encryption->decode($encoded_password); 
$decoded_username = $this->encryption->decode($encoded_username);

我在这里做错了吗?

更新:我尝试加密一个字符串,然后打印它,然后解密并打印,加密后返回NULL / Empty,解密后返回NULL / Empty(显而易见)。
代码低于

UPDATE: i tried encrypting a string and PRINT IT then decrypt and PRINT, After encryption it returns NULL/Empty and after decryption it returns NULL/Empty (Obvious). Code is below

$encval = $this->encryption->encode('codeigniter');
echo $encval.'  --  IT WAS --'.'codeigniter';
echo "<br>---------------------------------------------------<br>";
echo $this->encryption->decode($encval);

输出:^ Nothing

OUTPUT: ^Nothing

推荐答案

看,在CI中有2种使用加密的方法,并且两种都不应该用于密码(使用散列)。首先找出使用哪个密码对密码进行加密,然后将其存储在数据库中。此外,在对密码进行加密时也可能使用了某种KEY。

Look, there are 2 ways to use encryption in CI and both should not be used for password(use hashing). First find out which one was used to encrypt the password and then stored in DB.Also, its possible some kind of KEY may have been used while encrypting the password check this too.

下面是CI中可用的2个加密库。

Below are the 2 encryption libs available in CI.

1.Encrypt类: https://www.codeigniter.com/user_guide/libraries/encrypt.html

1.Encrypt class : https://www.codeigniter.com/user_guide/libraries/encrypt.html

2。加密库: https://www.codeigniter.com/user_guide/libraries/encryption.html

这篇关于codeigniter加密/解密函数返回空字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆