问题
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.
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
And a similar post on Stackoverflow
Secure keypair encryption solution in Delphi & 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 ?
回答1:
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.
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. 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.
来源:https://stackoverflow.com/questions/12138244/aes-encrypt-decrypt-delphi-php