douzhajie7168 2019-08-12 11:22
浏览 190

如何从openssl_decrypt文本和密钥中提取? - PHP

I'm trying to encrypt a word with a key and i found out openssl_encrypt.

Now (maybe) i'm able to do it but i can't to extract from it initial word and secret key.

 $text = "message";
 $method = "aes-128-gcm";
 $ivlen = openssl_cipher_iv_length($method);
 $iv = openssl_random_pseudo_bytes($ivlen);
 $secretKey= "god";


if (in_array($method, openssl_get_cipher_methods())){       
  $encrypted = openssl_encrypt($text, $method, $secretKey, $options=0, $iv);
  $decrypted = openssl_decrypt($encrypted, $method, $secretKey, $options=0, $iv);

  print_r($encrypted);

  print_r($decrypted);  
}

Besides when decryption is correct output is FALSE or TRUE ?

  • 写回答

1条回答 默认 最新

  • douyi6960 2019-08-12 11:40
    关注

    It's because you're using gcm, change $method to "aes-128-cbc"

    评论

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办