简体   繁体   English

AES加密/解密Delphi和PHP

[英]AES Encrypt/Decrypt Delphi & PHP

My Delphi application uses TurboPower LockBox 3 to encrypt a plaintext information using AES 256. I now want to decrypt this information using PHP. 我的Delphi应用程序使用TurboPower LockBox 3通过AES 256加密明文信息。我现在想使用PHP解密该信息。 But TurboPower LockBox 3 has some interoperability issues. 但是TurboPower LockBox 3存在一些互操作性问题。

Please check the post by LockBox 3 author here for details : 请在此处查看LockBox 3作者的帖子,以了解详细信息:

http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?comments_parentId=363&topics_offset=1 http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?comments_parentId=363&topics_offset=1

And a similar post on Stackoverflow 还有关于Stackoverflow的类似文章

Secure keypair encryption solution in Delphi & PHP? Delphi和PHP中的安全密钥对加密解决方案?

In LockBox 3, during encryption, you set a password. 在加密期间,在LockBox 3中设置密码。 This password is then used as a seed to generate the key and iv. 然后将此密码用作生成密钥和iv的种子。 So has anyone been able to mimic the key generation method on PHP side ? 那么有人能模仿PHP方面的密钥生成方法吗? 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 ? 还是有什么办法可以让LockBox 3生成Key / IV并将其放入我的PHP代码中,以便可以对文件进行解密?

IV IV

As stated to you before, the IV nonce is prepended to the ciphertext message. 如前所述,IV随机数位于密文消息之前。 So to obtain it on the PHP side, simply extract the first 8 bytes. 因此,要在PHP端获取它,只需提取前8个字节即可。

Keys 按键

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. symetric Key类(TSymetricKey)具有方法SaveToStream(),该方法可以按您期望的那样工作。 The TCodec component has a Key property, which will be available after you set the cipher, chaining mode and password. TCodec组件具有Key属性,在您设置密码,链接模式和密码后,该属性将可用。

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. 所有这些方法都是自记录的,它们的读取效果几乎一样,但是,如果您需要一些演示代码,将密钥保存到流中,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM