企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
# Sodium(+) 加密扩展 mcrypt 在 PHP 7.2 中已经移除,从PHP 7.2.0开始,libsodium扩展与PHP捆绑在一起。对于较旧的PHP版本,可以通过PECL<https://pecl.php.net/package/libsodium>获得此扩展。 Sodium:一个提供加密、解密、签名等功能的软件库 - [预定义常量](https://www.php.net/manual/en/sodium.constants.php) - [sodium函数](https://www.php.net/manual/en/ref.sodium.php) - [sodium\_add](https://www.php.net/manual/en/function.sodium-add.php)—[加大](https://www.php.net/manual/en/function.sodium-add.php)数 - [sodium\_base642bin](https://www.php.net/manual/en/function.sodium-base642bin.php)—说明 - [sodium\_bin2base64](https://www.php.net/manual/en/function.sodium-bin2base64.php)—说明 - [sodium\_bin2hex](https://www.php.net/manual/en/function.sodium-bin2hex.php)—编码为十六进制 - [sodium\_compare](https://www.php.net/manual/en/function.sodium-compare.php)—比较大数 - [sodium\_crypto\_aead\_aes256gcm\_decrypt](https://www.php.net/manual/en/function.sodium-crypto-aead-aes256gcm-decrypt.php)—在组合模式下通过预先计算进行解密 - [sodium\_crypto\_aead\_aes256gcm\_encrypt](https://www.php.net/manual/en/function.sodium-crypto-aead-aes256gcm-encrypt.php)—结合结合使用预先计算的模式进行加密 - [sodium\_crypto\_aead\_aes256gcm\_is\_available](https://www.php.net/manual/en/function.sodium-crypto-aead-aes256gcm-is-available.php)—检查硬件是否支持AES256-GCM - [sodium\_crypto\_aead\_aes256gcm\_keygen](https://www.php.net/manual/en/function.sodium-crypto-aead-aes256gcm-keygen.php)—获取密钥的随机字节 - [sodium\_crypto\_aead\_chacha20poly1305\_decrypt](https://www.php.net/manual/en/function.sodium-crypto-aead-chacha20poly1305-decrypt.php)—验证密文是否包含有效标签 - [sodium\_crypto\_aead\_chacha20poly1305\_encrypt](https://www.php.net/manual/en/function.sodium-crypto-aead-chacha20poly1305-encrypt.php)—加密消息 - [sodium\_crypto\_aead\_chacha20poly1305\_ietf\_decrypt](https://www.php.net/manual/en/function.sodium-crypto-aead-chacha20poly1305-ietf-decrypt.php)—验证密文是否包含有效标签 - [sodium\_crypto\_aead\_chacha20poly1305\_ietf\_encrypt](https://www.php.net/manual/en/function.sodium-crypto-aead-chacha20poly1305-ietf-encrypt.php)—加密消息 - [sodium\_crypto\_aead\_chacha20poly1305\_ietf\_keygen](https://www.php.net/manual/en/function.sodium-crypto-aead-chacha20poly1305-ietf-keygen.php)—获取密钥的随机字节 - [sodium\_crypto\_aead\_chacha20poly1305\_keygen](https://www.php.net/manual/en/function.sodium-crypto-aead-chacha20poly1305-keygen.php)—获取密钥的随机字节 - [sodium\_crypto\_aead\_xchacha20poly1305\_ietf\_decrypt](https://www.php.net/manual/en/function.sodium-crypto-aead-xchacha20poly1305-ietf-decrypt.php)—说明 - [sodium\_crypto\_aead\_xchacha20poly1305\_ietf\_encrypt](https://www.php.net/manual/en/function.sodium-crypto-aead-xchacha20poly1305-ietf-encrypt.php)—说明 - [sodium\_crypto\_aead\_xchacha20poly1305\_ietf\_keygen](https://www.php.net/manual/en/function.sodium-crypto-aead-xchacha20poly1305-ietf-keygen.php)—说明 - [sodium\_crypto\_auth\_keygen](https://www.php.net/manual/en/function.sodium-crypto-auth-keygen.php)—获取密钥的随机字节 - [sodium\_crypto\_auth\_verify](https://www.php.net/manual/en/function.sodium-crypto-auth-verify.php)—验证标签对消息有效 - [sodium\_crypto\_auth](https://www.php.net/manual/en/function.sodium-crypto-auth.php)—计算消息的标签 - [sodium\_crypto\_box\_keypair\_from\_secretkey\_and\_publickey](https://www.php.net/manual/en/function.sodium-crypto-box-keypair-from-secretkey-and-publickey.php)—说明 - [sodium\_crypto\_box\_keypair](https://www.php.net/manual/en/function.sodium-crypto-box-keypair.php)—随机生成一个秘密密钥和一个对应的公共密钥 - [sodium\_crypto\_box\_open](https://www.php.net/manual/en/function.sodium-crypto-box-open.php)—验证[和解密密](https://www.php.net/manual/en/function.sodium-crypto-box-open.php)文 - [sodium\_crypto\_box\_publickey\_from\_secretkey](https://www.php.net/manual/en/function.sodium-crypto-box-publickey-from-secretkey.php)—说明 - [sodium\_crypto\_box\_publickey-](https://www.php.net/manual/en/function.sodium-crypto-box-publickey.php)说明 - [sodium\_crypto\_box\_seal\_open](https://www.php.net/manual/en/function.sodium-crypto-box-seal-open.php)—解密密文 - [sodium\_crypto\_box\_seal](https://www.php.net/manual/en/function.sodium-crypto-box-seal.php)—加密消息 - [sodium\_crypto\_box\_secretkey](https://www.php.net/manual/en/function.sodium-crypto-box-secretkey.php)—说明 - [sodium\_crypto\_box\_seed\_keypair](https://www.php.net/manual/en/function.sodium-crypto-box-seed-keypair.php)—确定性地从单个密钥导出密钥对 - [sodium\_crypto\_box](https://www.php.net/manual/en/function.sodium-crypto-box.php)—加密消息 - [sodium\_crypto\_generichash\_final](https://www.php.net/manual/en/function.sodium-crypto-generichash-final.php)—完成哈希 - [sodium\_crypto\_generichash\_init](https://www.php.net/manual/en/function.sodium-crypto-generichash-init.php)—初始化哈希 - [sodium\_crypto\_generichash\_keygen](https://www.php.net/manual/en/function.sodium-crypto-generichash-keygen.php)—获取密钥的随机字节 - [sodium\_crypto\_generichash\_update](https://www.php.net/manual/en/function.sodium-crypto-generichash-update.php)—将消息添加到哈希 - [sodium\_crypto\_generichash](https://www.php.net/manual/en/function.sodium-crypto-generichash.php)—获取消息的哈希值 - [sodium\_crypto\_kdf\_derive\_from\_key](https://www.php.net/manual/en/function.sodium-crypto-kdf-derive-from-key.php)—派生一个子项 - [sodium\_crypto\_kdf\_keygen](https://www.php.net/manual/en/function.sodium-crypto-kdf-keygen.php)—获取密钥的随机字节 - [sodium\_crypto\_kx\_client\_session\_keys](https://www.php.net/manual/en/function.sodium-crypto-kx-client-session-keys.php)—说明 - [sodium\_crypto\_kx\_keypair](https://www.php.net/manual/en/function.sodium-crypto-kx-keypair.php)—创建一个新的sodium密钥对 - [sodium\_crypto\_kx\_publickey](https://www.php.net/manual/en/function.sodium-crypto-kx-publickey.php)—说明 - [sodium\_crypto\_kx\_secretkey](https://www.php.net/manual/en/function.sodium-crypto-kx-secretkey.php)—说明 - [sodium\_crypto\_kx\_seed\_keypair](https://www.php.net/manual/en/function.sodium-crypto-kx-seed-keypair.php)—说明 - [sodium\_crypto\_kx\_server\_session\_keys](https://www.php.net/manual/en/function.sodium-crypto-kx-server-session-keys.php)—说明 - [sodium\_crypto\_pwhash\_scryptsalsa208sha256\_str\_verify](https://www.php.net/manual/en/function.sodium-crypto-pwhash-scryptsalsa208sha256-str-verify.php)—验证密码是否为有效的密码验证字符串 - [sodium\_crypto\_pwhash\_scryptsalsa208sha256\_str](https://www.php.net/manual/en/function.sodium-crypto-pwhash-scryptsalsa208sha256-str.php)—获取ASCII编码的哈希 - [sodium\_crypto\_pwhash\_scryptsalsa208sha256](https://www.php.net/manual/en/function.sodium-crypto-pwhash-scryptsalsa208sha256.php)—从密码[派生](https://www.php.net/manual/en/function.sodium-crypto-pwhash-scryptsalsa208sha256.php)密钥 - [sodium\_crypto\_pwhash\_str\_needs\_rehash](https://www.php.net/manual/en/function.sodium-crypto-pwhash-str-needs-rehash.php)—说明 - [sodium\_crypto\_pwhash\_str\_verify](https://www.php.net/manual/en/function.sodium-crypto-pwhash-str-verify.php)—验证密码是否匹配哈希 - [sodium\_crypto\_pwhash\_str](https://www.php.net/manual/en/function.sodium-crypto-pwhash-str.php)—获取ASCII编码的哈希 - [sodium\_crypto\_pwhash](https://www.php.net/manual/en/function.sodium-crypto-pwhash.php)—从密码派生密钥 - [sodium\_crypto\_scalarmult\_base](https://www.php.net/manual/en/function.sodium-crypto-scalarmult-base.php)—[sodium\_crypto\_box\_publickey\_from\_secretkey的](https://www.php.net/manual/en/function.sodium-crypto-scalarmult-base.php)别名 - [sodium\_crypto\_scalarmult](https://www.php.net/manual/en/function.sodium-crypto-scalarmult.php)—给定用户的密钥和另一个用户的公共密钥,计算共享密钥 - [sodium\_crypto\_secretbox\_keygen](https://www.php.net/manual/en/function.sodium-crypto-secretbox-keygen.php)—获取密钥的随机字节 - [sodium\_crypto\_secretbox\_open](https://www.php.net/manual/en/function.sodium-crypto-secretbox-open.php)—验证[和解密密](https://www.php.net/manual/en/function.sodium-crypto-secretbox-open.php)文 - [sodium\_crypto\_secretbox](https://www.php.net/manual/en/function.sodium-crypto-secretbox.php)—加密消息 - [sodium\_crypto\_secretstream\_xchacha20poly1305\_init\_pull](https://www.php.net/manual/en/function.sodium-crypto-secretstream-xchacha20poly1305-init-pull.php)—说明 - [sodium\_crypto\_secretstream\_xchacha20poly1305\_init\_push](https://www.php.net/manual/en/function.sodium-crypto-secretstream-xchacha20poly1305-init-push.php)—说明 - [sodium\_crypto\_secretstream\_xchacha20poly1305\_keygen](https://www.php.net/manual/en/function.sodium-crypto-secretstream-xchacha20poly1305-keygen.php)—说明 - [sodium\_crypto\_secretstream\_xchacha20poly1305\_pull](https://www.php.net/manual/en/function.sodium-crypto-secretstream-xchacha20poly1305-pull.php)—说明 - [sodium\_crypto\_secretstream\_xchacha20poly1305\_push](https://www.php.net/manual/en/function.sodium-crypto-secretstream-xchacha20poly1305-push.php)—说明 - [sodium\_crypto\_secretstream\_xchacha20poly1305\_rekey](https://www.php.net/manual/en/function.sodium-crypto-secretstream-xchacha20poly1305-rekey.php)—说明 - [sodium\_crypto\_shorthash\_keygen](https://www.php.net/manual/en/function.sodium-crypto-shorthash-keygen.php)—获取密钥的随机字节 - [sodium\_crypto\_shorthash](https://www.php.net/manual/en/function.sodium-crypto-shorthash.php)—计算消息的固定大小的指纹 - [sodium\_crypto\_sign\_detached](https://www.php.net/manual/en/function.sodium-crypto-sign-detached.php)—对消息签名 - [sodium\_crypto\_sign\_ed25519\_pk\_to\_curve25519](https://www.php.net/manual/en/function.sodium-crypto-sign-ed25519-pk-to-curve25519.php)—将Ed25519公钥转换为Curve25519公钥 - [sodium\_crypto\_sign\_ed25519\_sk\_to\_curve25519](https://www.php.net/manual/en/function.sodium-crypto-sign-ed25519-sk-to-curve25519.php)—将Ed25519秘密密钥转换为Curve25519秘密密钥 - [sodium\_crypto\_sign\_keypair\_from\_secretkey\_and\_publickey](https://www.php.net/manual/en/function.sodium-crypto-sign-keypair-from-secretkey-and-publickey.php)—说明 - [sodium\_crypto\_sign\_keypair](https://www.php.net/manual/en/function.sodium-crypto-sign-keypair.php)—随机生成一个秘密密钥和一个对应的公共密钥 - [sodium\_crypto\_sign\_open](https://www.php.net/manual/en/function.sodium-crypto-sign-open.php)—检查已签名的消息是否具有有效的签名 - [sodium\_crypto\_sign\_publickey\_from\_secretkey](https://www.php.net/manual/en/function.sodium-crypto-sign-publickey-from-secretkey.php)—从[私钥中](https://www.php.net/manual/en/function.sodium-crypto-sign-publickey-from-secretkey.php)提取公钥 - [sodium\_crypto\_sign\_publickey](https://www.php.net/manual/en/function.sodium-crypto-sign-publickey.php)—说明 - [sodium\_crypto\_sign\_secretkey](https://www.php.net/manual/en/function.sodium-crypto-sign-secretkey.php)—说明 - [sodium\_crypto\_sign\_seed\_keypair](https://www.php.net/manual/en/function.sodium-crypto-sign-seed-keypair.php)—从单个密钥确定性地导出密钥对 - [sodium\_crypto\_sign\_verify\_detached](https://www.php.net/manual/en/function.sodium-crypto-sign-verify-detached.php)—验证消息的签名 - [sodium\_crypto\_sign](https://www.php.net/manual/en/function.sodium-crypto-sign.php)—签名消息 - [sodium\_crypto\_stream\_keygen](https://www.php.net/manual/en/function.sodium-crypto-stream-keygen.php)—获取密钥的随机字节 - [sodium\_crypto\_stream\_xor](https://www.php.net/manual/en/function.sodium-crypto-stream-xor.php)—加密消息 - [sodium\_crypto\_stream](https://www.php.net/manual/en/function.sodium-crypto-stream.php)—从种子生成确定的字节序列 - [sodium\_hex2bin](https://www.php.net/manual/en/function.sodium-hex2bin.php)—解码十六进制编码的二进制字符串 - [sodium\_increment](https://www.php.net/manual/en/function.sodium-increment.php)—增加数量 - [sodium\_memcmp](https://www.php.net/manual/en/function.sodium-memcmp.php)—恒定时间测试相等性 - [sodium\_memzero](https://www.php.net/manual/en/function.sodium-memzero.php)—用零覆盖buf - [sodium\_pad](https://www.php.net/manual/en/function.sodium-pad.php)—添加填充数据 - [sodium\_unpad](https://www.php.net/manual/en/function.sodium-unpad.php)—删除填充数据