较新版本的Delphi提供了Winapi.Security.Cryptography单元。

unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
Vcl.StdCtrls, Vcl.ComCtrls, Winapi.Security.Cryptography,
Winapi.WinRT, Winapi.CommonTypes, System.Win.WinRT;
type
TForm1 = class(TForm)
RichEdit: TRichEdit;
procedure FormCreate(Sender: TObject);
private
procedure SymmKeyAlgProviderApp;
function SampleCipherEncryption(
strMsg: HString ;
strAlgName: HString;
keyLength: UInt32;
var encoding: BinaryStringEncoding;
var iv: IBuffer;
var key: Core_ICryptographicKey): IBuffer;
procedure SampleCipherDecryption(
strAlgName: HString;
buffEncrypt: IBuffer;
iv: IBuffe

这篇博客介绍了如何在较新版本的Delphi中使用Winapi.Security.Cryptography单元进行对称加密和解密操作。通过示例代码展示了3DES-CBC-Pkcs7算法的使用,包括创建密钥、初始化向量、加密和解密过程,以及错误检查和结果展示。

2887

被折叠的 条评论
为什么被折叠?



