api接口数据怎么加密

674
2021/3/5 12:48:22
栏目: 网络安全
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

api接口数据怎么加密

使用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);

}

辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读: vb中如何在数据文件加密码