- 授权协议: GPLv3
- 开发语言: PHP
- 操作系统: 跨平台
- 软件首页: https://paragonie.com/project/halite
- 软件文档: https://github.com/paragonie/halite/blob/master/README.md
- 官方下载: https://github.com/paragonie/halite/archive/master.zip
软件介绍
Halite 是PHP项目中一个简单的libsodium封装包。Halite提供高级的加密接口,依靠其所有潜在的密码操作libsodium。
Halite 基本 API:
Encryption
Anonymous
Authenticated
Asymmetric\Crypto::seal
(HiddenString
,EncryptionPublicKey
):string
Asymmetric\Crypto::unseal
(string
,EncryptionSecretKey
):HiddenString
Asymmetric\Crypto::encrypt
(HiddenString
,EncryptionSecretKey
,EncryptionPublicKey
):string
Asymmetric\Crypto::decrypt
(string
,EncryptionSecretKey
,EncryptionPublicKey
):HiddenString
Symmetric\Crypto::encrypt
(HiddenString
,EncryptionKey
):string
Symmetric\Crypto::decrypt
(string
,EncryptionKey
):HiddenString
Symmetric
Asymmetric
Authentication
Asymmetric\Crypto::sign
(string
,SignatureSecretKey
):string
Asymmetric\Crypto::verify
(string
,SignaturePublicKey
,string
):bool
Symmetric\Crypto::authenticate
(string
,AuthenticationKey
):string
Symmetric\Crypto::verify
(string
,AuthenticationKey
,string
):bool
Symmetric
Asymmetric
示例1:加密解密消息
首先,生成一个key
<?php use ParagonIE\Halite\KeyFactory; $encKey = KeyFactory::generateEncryptionKey(); KeyFactory::save($encKey, '/path/outside/webroot/encryption.key');
然后,加密解密消息
<?php use ParagonIE\Halite\HiddenString; use ParagonIE\Halite\KeyFactory; use ParagonIE\Halite\Symmetric\Crypto as Symmetric; $encryptionKey = KeyFactory::loadEncryptionKey('/path/outside/webroot/encryption.key'); $message = new HiddenString('This is a confidential message for your eyes only.'); $ciphertext = Symmetric::encrypt($message, $encryptionKey); $decrypted = Symmetric::decrypt($ciphertext, $encryptionKey); var_dump($decrypted === $message); // bool(true)
示例2:用password-derived key 加密消息
<?php use ParagonIE\Halite\HiddenString; use ParagonIE\Halite\KeyFactory; use ParagonIE\Halite\Symmetric\Crypto as Symmetric; $passwd = new HiddenString('correct horse battery staple'); // Use random_bytes(16); to generate the salt: $salt = "\xdd\x7b\x1e\x38\x75\x9f\x72\x86\x0a\xe9\xc8\x58\xf6\x16\x0d\x3b"; $encryptionKey = KeyFactory::deriveEncryptionKey($passwd, $salt); $message = new HiddenString('This is a confidential message for your eyes only.'); $ciphertext = Symmetric::encrypt($message, $encryptionKey); echo $ciphertext, "\n";
Ajax与PHP Web开发
达里 / 王德民、王新颖、刘昕 / 人民邮电出版社 / 2007-4 / 39.00元
本书指导读者使用Ajax、PHP及其他相关技术建立快速响应的网页。本书不仅从Ajax的客户端和服务器端技术两个方面指导读者逐步掌握Ajax基础应用,还通过实例详细演示了Ajax表单验证、Ajax聊天室、Ajax Suggest、使用SVG实现的Ajax实时绘图程序、Ajax Grid、Ajax RSS阅读器和Ajax拖放等的实现过程。同时还介绍了在Windows和UNIX系统下的应用程序环境配置和......一起来看看 《Ajax与PHP Web开发》 这本书的介绍吧!