加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 在X处拆分字符串,然后在Y值处拆分

发布时间:2020-12-13 22:49:04 所属栏目:PHP教程 来源:网络整理
导读:我有以下代码: $Field = $FW-Encrypt("Test");echo "pre";print_r($Field);echo "/pre";# $IV_Count = strlen($Field['IV']);# $Key_Count = strlen($Field['Key']);# $Cipher_Count = strlen($Field['CipheredText']);foreach ($Field AS $Keys = $Values)
我有以下代码:

$Field = $FW->Encrypt("Test");

echo "<pre>";
print_r($Field);
echo "</pre>";
#  $IV_Count = strlen($Field['IV']);
#  $Key_Count = strlen($Field['Key']);
#  $Cipher_Count = strlen($Field['CipheredText']);

foreach ($Field AS $Keys => $Values){
    echo $Keys."Count = ".strlen($Values)."<br><br>";
}

输出如下:

06001

无论输入如何,IV / KeyCount始终返回相同的值.但是CipheredTextCount根据输入而改变.例如:

$Field = $FW->Encrypt("This is a longer string");

foreach循环返回:

CipheredTextCount = 64

IVCount = 2

KeyCount = 16

现在我的问题.让我们看一下TextCount为44的第一个例子

内爆后如何拆分字符串(“”,$Field);显示为原始数组?一个例子是:

echo implode("",$Field);

哪个输出:

ijGglH/vysf52J5aoTaDVHy4oavEBK4mZTrAL3lZMTI=16III#TcTf?eB12T

根据strlen的结果?

可以将第一个$Cipher_Count的计数存储在数据库中以供参考

我当前的设置涉及将密钥和IV存储在远离加密文本字符串的单独列中.我需要将其包含在一个字段中,并且脚本处理所需信息以执行以下操作:

Retrieve The long string > Split string to the original array > Push
array to another function > decrypt > return decoded string.

解决方法

为什么不使用 serialize呢?然后,当您从数据库中获取数据时,可以使用 unserialize将其还原为数组.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读