使用AES加密算法对api接口数据进行加密,具体方法如下:
//$key previously generated safely, ie: openssl_random_pseudo_bytes
$key='123456789';
$plaintext="hello world";
//$cipher = "aes-128-cbc";
$cipher = "AES-128-ECB";
if (in_array($cipher, openssl_get_cipher_methods()))
{
// $iv='1111111111111111';
$iv='';
$ciphertext = openssl_encrypt($plaintext, $cipher, $key, OPENSSL_RAW_DATA, $iv);
$ciphertext =base64_encode($ciphertext);
//store $cipher, $iv, and $tag for decryption later
$original_plaintext = openssl_decrypt(base64_decode($ciphertext), $cipher, $key, OPENSSL_RAW_DATA, $iv);
var_dump( $original_plaintext);
var_dump( $ciphertext);
}
--结束END--
本文标题: api接口数据怎么加密
本文链接: https://www.lsjlt.com/news/113137.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-04-27
2024-04-27
2024-04-27
2024-04-27
2024-04-27
2024-04-27
2024-04-27
2024-04-27
2024-04-27
2024-04-27
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0