如何使用Libsodium-PHP加密/解密AES [英] How to encrypt / decrypt AES with Libsodium-PHP

查看:298
本文介绍了如何使用Libsodium-PHP加密/解密AES的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要使用PHP加密/解密数据。我是全新的,但是我已经看到,Libsodium-PHP是AES加密的最佳工具。很像我研究的其他PHP加密库,Libsoduim-PHP似乎几乎没有提供如何使用库(我能够找到)的文档。任何有PHP加密经验的人都可以将我指向好的学习资源,或者使用Libsoduim-PHP编写几行示例代码?
非常感谢您的帮助,

Atlas


I need to encrypt/decrypt data with PHP. I am completely new to this, however I have read that Libsodium-PHP is the best tool for AES encryption. Much like the other PHP encryption libraries I have researched Libsoduim-PHP seemed to offer almost no documentation of how to use the library (that I was able to find). Can anyone that has experience with PHP encryption either point me in the direction of a good learning resource or write a few lines of sample code using Libsoduim-PHP?
Thank you very much for the help,
Atlas

推荐答案


很像我研究过的其他PHP加密库Libsoduim-PHP似乎几乎提供没有关于如何使用库的文档(我能够找到)。

Much like the other PHP encryption libraries I have researched Libsoduim-PHP seemed to offer almost no documentation of how to use the library (that I was able to find).

libsodium-php Github页面,您将找到一个直接链接到一个免费的在线 ,涵盖开始使用libsodium所需的一切。

From the libsodium-php Github page you will find a direct link to a free online book that covers everything you need to know to get started with libsodium.

最后一章包含 libsodium食谱,但每章包含detaile d使用信息。

The final chapter contains libsodium recipes, but each chapter contains detailed usage information.

如果您特别需要AES,阅读这个

If you specifically need AES, read this.

如果你没有AES-or-bust要求挂在你的头上,在那里没有具体使用AES意味着你的部门被斧头,你的开发人员面对一个射击队,你应该考虑只使用 crypto_secretbox ,它使用Xsalsa20进行加密,并附加Poly1305认证标签。 (这是验证加密,您要使用几乎总是。)

If you don't have an "AES-or-bust" requirement hanging over your head, where failure to specifically use AES means your department gets axed and your developers face a firing squad, you should consider just using crypto_secretbox which uses Xsalsa20 for encryption and attaches a Poly1305 authentication tag. (This is authenticated encryption, which you want to use almost always.)

同时查看 Halite 如果你想要简单模式。

Also look into Halite if you want easy-mode.

这篇关于如何使用Libsodium-PHP加密/解密AES的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆