我在C#中有下一个代码
DESCryptoServiceProvider Crypto = new DESCryptoServiceProvider();
Crypto.BlockSize = 64;
Crypto.FeedbackSize = 8;
Crypto.Mode = CipherMode.ECB;
Crypto.Padding = PaddingMode.None;
Encryptor = Crypto.CreateEncryptor(Encoding.ASCII.GetBytes("key"), Encoding.UTF8.GetBytes("ivkey"));
Decryptor = Crypto.CreateDecryptor(Encoding.ASCII.GetBytes("key"), Encoding.UTF8.GetBytes("ivkey"));
我需要将其传递给Builder C ++(delphi也可以)。我已经可以在我的proyect中编译密码箱3.7库(https://github.com/TurboPack/LockBox3),但是我不确定如何设置不同的参数
TSimpleCodec *cypher;
...
try {
cypher=new TSimpleCodec();
cypher->Reset();
//HERE is where i need help
cypher->EncryptStream(ms,ms2);
} catch (...) {
}
在delphi / builder上的任何其他工作库也可以。
欢迎任何提示。谢谢,
这是使用LockBox 3.7进行AES编码/解码的一个小示例。
void __fastcall TForm1::EncodeDecodeClick(TObject *Sender){
Codec1->CryptoLibrary = CryptographicLibrary1;
Codec1->BlockCipherId = "native.AES-256"; // or some other
Codec1->ChainModeId = "native.CBC";
Codec1->Password = "secret_key";
String SecretMessage = "Secret message";
String EncodedMessage;
Codec1->EncryptString(SecretMessage, EncodedMessage, TEncoding::UTF8);
ShowMessage(EncodedMessage); // e.g. WfmyxjfoGZh3Ky6UoTryvjDsqzM=
Codec1->DecryptString(SecretMessage, EncodedMessage, TEncoding::UTF8);
ShowMessage(SecretMessage); // Secret message
}