gpt4 book ai didi

php - 锂钠 "Call to undefined function sodium_randombytes_buf"

转载 作者:行者123 更新时间:2023-12-01 16:04:47 24 4
gpt4 key购买 nike

<分区>

尝试遵循示例 here , 但它给了我

Fatal error: Uncaught Error: Call to undefined function sodium_randombytes_buf()

最重要的是, key 对似乎生成了奇怪的字符串,例如:

这正常吗?

这是我的代码

<?php

// send
$message = 'Hi, this is Alice';
$alice_to_bob_kp = sodium_crypto_box_keypair_from_secretkey_and_publickey(
file_get_contents('./keys/sec-user-1_box_key.txt'),
file_get_contents('./keys/pub-user-2_box_key.txt')
);
$nonce = sodium_randombytes_buf(SODIUM_CRYPTO_BOX_NONCEBYTES);
$ciphertext = sodium_crypto_box(
$message,
$nonce,
$alice_to_bob_kp
);




// receive
$bob_to_alice_kp = sodium_crypto_box_keypair_from_secretkey_and_publickey(
// $bob_box_secretkey,
// $alice_box_publickey
file_get_contents('./keys/sec-user-2_box_key.txt'),
file_get_contents('./keys/pub-user-1_box_key.txt')
);
$nonce = sodium_randombytes_buf(SODIUM_CRYPTO_BOX_NONCEBYTES);
$plaintext = sodium_crypto_box_open(
$ciphertext,
$nonce,
$bob_to_alice_kp
);
if ($plaintext === false) {
die("Malformed message or invalid MAC");
}
die($plaintext);

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com