AES 加密/解密 Delphi &PHP

AES Encrypt/Decrypt Delphi amp; PHP(AES 加密/解密 Delphi amp;PHP)
本文介绍了AES 加密/解密 Delphi &PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我的 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)