問題描述
我的 Delphi 應用程序使用 TurboPower LockBox 3 使用 AES 256 加密明文信息.我現在想使用 PHP 解密此信息.但是 TurboPower LockBox 3 存在一些互操作性問題.
My Delphi application uses TurboPower LockBox 3 to encrypt a plaintext information using AES 256. I now want to decrypt this information using PHP. But TurboPower LockBox 3 has some interoperability issues.
請在此處查看 LockBox 3 作者的帖子以了解詳細信息:
Please check the post by LockBox 3 author here for details :
http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?comments_parentId=363&topics_offset=1
還有一篇關于 Stackoverflow 的類似帖子
And a similar post on Stackoverflow
Delphi 中的安全密鑰對加密解決方案 &PHP?
在 LockBox 3 中,在加密期間,您設置密碼.然后將此密碼用作生成密鑰和 iv 的種子.那么有沒有人能夠模仿 PHP 端的密鑰生成方法?或者有什么方法可以讓我獲得 LockBox 3 生成的密鑰/IV 并將其放入我的 PHP 代碼中,以便可以解密文件?
In LockBox 3, during encryption, you set a password. This password is then used as a seed to generate the key and iv. So has anyone been able to mimic the key generation method on PHP side ? Or is there any way i can get the Key/IV being generated by LockBox 3 and put it in my PHP code so the file can be decrypted ?
推薦答案
IV
如前所述,IV nonce 被添加到密文消息中.所以要在 PHP 端獲取它,只需提取前 8 個字節即可.
IV
As stated to you before, the IV nonce is prepended to the ciphertext message. So to obtain it on the PHP side, simply extract the first 8 bytes.
您需要決定共享密鑰是密碼字符串格式還是二進制密鑰格式.symetric Key 類 (TSymetricKey) 有一個 SaveToStream() 方法,它按您的預期工作.TCodec 組件有一個 Key 屬性,設置密碼、鏈接模式和密碼后即可使用.
You need to decide if the shared secret is in password-string format or binary key format. The symetric Key class (TSymetricKey) has a method SaveToStream(), which works as you would expect it to. The TCodec component has a Key property, which will be available after you set the cipher, chaining mode and password.
所有方法都是自文檔化的,并且幾乎按照它們的閱讀方式執行,但是如果您需要一些演示代碼,將密鑰保存到流中,請告訴我.
All of the methods are self-documenting and do pretty much what they read like, however if you need some demo code, saving a key to a stream, let me know.
這篇關于AES 加密/解密 Delphi &PHP的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!