openssl_decrypt不解密使用openssl_encrypt存储的数据

时间:2019-11-15 20:18:48

标签: php openssl php-openssl

我需要对无法存储为纯文本格式的非敏感数据进行简单的加密/解密。我把这个类放在一起,openssl_decrypt返回的是false,但我不知道为什么。

fflush(stdin)

1 个答案:

答案 0 :(得分:2)

您没有存储从加密过程返回的标签值。作为mentioned in the documentation,对于GCM和CCM密码,这是必需的。

还清理了一下代码:

<br />
1 this was encrpyted
<br />
2 {"key":"3b48ecde64b8e2789991604678cc9fb9","iv":"307443dc8d114773fc02d0c4","tag":"8c66a2b0094435345b751b2dec5231a9","ciphertext":"EiIxe2hp0aONf41oBRuvwtjr"}
<br />
3 this was encrpyted

输出:

for i in range (0,4):
  l=[]
  for j in range (1+i,6+i):
    l.append (j)
  print(l)