⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pgpcl.pas

📁 用DELPHI实现的 PGP 加密算法
💻 PAS
📖 第 1 页 / 共 2 页
字号:
const
  RELOADKEYRINGMSG6 = 'PGPM_RELOADKEYRING';
  RELOADKEYRINGMSG7 = 'PGP Keyrings Reload';

var
  PGPclNotifyKeyringChanges6: procedure(lParam: Longint); cdecl;
  PGPclNotifyKeyringChanges7: procedure(wParam, lParam: Longint); stdcall;

//	Broadcast message that indicates that the keyserver prefs
//	have been changed and that others should reload from
//	disk.
//
//	Entry parameters :
//		lParam		- 32 value which is passed along as the LPARAM
//				  of the broadcast message.  Current usage
//				  is to set this to your process ID or your
//				  window handle so that you can ignore
//				  your own messages, if you want.  Set to
//				  zero to ensure all recipients process message.

//	broadcast message used to inform others of keyserver prefs changes

const
  RELOADKEYSERVERPREFSMSG6 = 'PGPM_RELOADKEYSERVERPREFS';
  RELOADKEYSERVERPREFSMSG7 = 'PGP Keyserver Prefs Reload';

var
  PGPclNotifyKeyserverPrefsChanges6: procedure(lParam: Longint); cdecl;
  PGPclNotifyKeyserverPrefsChanges7: procedure(lParam: Longint); stdcall;


//	_______________________________________________________
//
//	Miscellaneous common dialogs and UI elements

// option flag bits

const	// added by idw
  PGPCL_SINGLESELECTION		= 1;

var	// added by idw
  PGPclSelectKeysEx6: function(Context: pPGPContext;
			       tlsContext: pPGPtlsContext;
			       hWndParent: Longint;
			       pszPrompt: PChar;
			       KeySetToDisplay: pPGPKeySet;
			       KeySetMain: pPGPKeySet;
			       Flags: Longint;
			       var KeySetSelected: pPGPKeySet): PGPError; cdecl;
var	// added by idw
  PGPclSelectKeysEx7: function(Context: pPGPContext;
			       tlsContext: pPGPtlsContext;
			       hWndParent: Longint;
			       pszPrompt: PChar;
			       KeySetToDisplay: pPGPKeySet;
			       Flags: Longint;
			       var KeySetSelected: pPGPKeySet): PGPError; stdcall;

//	display keyset and allow user to select keys
//	- extended calling parameters -- added option flags
//
//	Entry parameters :
//		hWndParent		- handle of parent window
//		pszPrompt		- prompt string
//		KeySetToDisplay		- keyset containing keys to show
//		KeySetMain		- backing keyset
//		uFlags			- option flags (see below)
//		pKeySetSelected		- buffer to receive keyset ref of selected keys
//
//
//	Returns kPGPError_NoErr if no error
//

//	_______________________________________________________

// wrapper functions for version compatibility
function PGPclInitLibrary(Context: pPGPContext; Options: PGPFlags): PGPError;
function PGPclCloseLibrary: PGPError;
function PGPclPreferences(Context: pPGPContext; hWndParent: Longint; iStartsheet: Longint; KeySetMain: pPGPKeySet): PGPError;
function PGPclGetPrefBoolean(PGPPref: pPGPPref; PrefIndex: PGPPrefIndex; var Data: PGPBoolean): PGPError;
function PGPclSetPrefBoolean(PGPPref: pPGPPref; PrefIndex: PGPPrefIndex; Data: PGPBoolean): PGPError;
function PGPclGetPrefNumber(PGPPref: pPGPPref; PrefIndex: PGPPrefIndex; var Data: PGPUInt32): PGPError;
function PGPclSetPrefNumber(PGPPref: pPGPPref; PrefIndex: PGPPrefIndex; Data: PGPUInt32): PGPError;
function PGPclGetPrefStringAlloc(PGPPref: pPGPPref; PrefIndex: PGPPrefIndex; var Str: PChar): PGPError;
function PGPclGetPrefStringBuffer(PGPPref: pPGPPref; PrefIndex: PGPPrefIndex; MaxSize: PGPSize; Str: PChar): PGPError;
function PGPclSetPrefString(PGPPref: pPGPPref; PrefIndex: PGPPrefIndex; Str: PChar): PGPError;
function PGPclGetPrefData(PGPPref: pPGPPref; PrefIndex: PGPPrefIndex;
			  var DataLength: PGPSize; var InBuffer: Pointer): PGPError;
function PGPclSetPrefData(PGPPref: pPGPPref; PrefIndex: PGPPrefIndex;
			  DataLength: PGPSize; OutBuffer: Pointer): PGPError;
function PGPclRemovePref(PGPPref: pPGPPref; PrefIndex: PGPPrefIndex): PGPError;
function PGPclOpenClientPrefs(MemMgr: pPGPMemoryMgr; var PGPPref: pPGPPref): PGPError;
function PGPclCloseClientPrefs(PGPPref: pPGPPref; bSave: Longbool): PGPError;
procedure PGPclNotifyPrefsChanges(lParam: Longint);
procedure PGPclNotifyKeyringChanges(lParam: Longint);
procedure PGPclNotifyKeyserverPrefsChanges(lParam: Longint);
function PGPclSelectKeys(Context: pPGPContext;
			 tlsContext: pPGPtlsContext;
			 hWndParent: Longint;
			 pszPrompt: PChar;
			 KeySetToDisplay: pPGPKeySet;
			 KeySetMain: pPGPKeySet;
			 Flags: Longint;
			 var KeySetSelected: pPGPKeySet): PGPError;
function PGPGetKeyServerPrefs(Pref: pPGPPref;
			      var KeyServerList: pPGPKeyServerEntry;
			      var KeyServerCount: PGPUInt32): PGPError;
function PGPSetKeyServerPrefs(Pref: pPGPPref;
			      KeyServerList: pPGPKeyServerEntry;
			      KeyServerCount: PGPUInt32): PGPError;

implementation	// code modified by idw

function PGPclInitLibrary(Context: pPGPContext; Options: PGPFlags): PGPError;
var
  Dummy: pPGPContext;
begin
  if PGP7X then 
    Result:=PGPclInitLibrary7(Dummy, Options)
  else Result:=PGPclInitLibrary6(Context);
end;

function PGPclCloseLibrary: PGPError;
begin
  if PGP7X then
    Result:=PGPclCloseLibrary7
  else Result:=PGPclCloseLibrary6;
end;

function PGPclPreferences(Context: pPGPContext; hWndParent: Longint; iStartsheet: Longint; KeySetMain: pPGPKeySet): PGPError;
begin
  if PGP7X then
    Result:=PGPclPreferences7(Context, hWndParent, PGPCL_PREFPAGES7[iStartsheet], KeySetMain)
  else Result:=PGPclPreferences6(Context, hWndParent, iStartsheet, KeySetMain);
end;

function PGPclGetPrefBoolean(PGPPref: pPGPPref; PrefIndex: PGPPrefIndex; var Data: PGPBoolean): PGPError;
begin
  if PGP7X then
    Result:=PGPclGetPrefBoolean7(PGPPref, PrefIndex, Data)
  else Result:=PGPclGetPrefBoolean6(PGPPref, PrefIndex, Data);
end;

function PGPclSetPrefBoolean(PGPPref: pPGPPref; PrefIndex: PGPPrefIndex; Data: PGPBoolean): PGPError;
begin
  if PGP7X then
    Result:=PGPclSetPrefBoolean7(PGPPref, PrefIndex, Data)
  else Result:=PGPclSetPrefBoolean6(PGPPref, PrefIndex, Data);
end;

function PGPclGetPrefNumber(PGPPref: pPGPPref; PrefIndex: PGPPrefIndex; var Data: PGPUInt32): PGPError;
begin
  if PGP7X then
    Result:=PGPclGetPrefNumber7(PGPPref, PrefIndex, Data)
  else Result:=PGPclGetPrefNumber6(PGPPref, PrefIndex, Data);
end;

function PGPclSetPrefNumber(PGPPref: pPGPPref; PrefIndex: PGPPrefIndex; Data: PGPUInt32): PGPError;
begin
  if PGP7X then
    Result:=PGPclSetPrefNumber7(PGPPref, PrefIndex, Data)
  else Result:=PGPclSetPrefNumber6(PGPPref, PrefIndex, Data);
end;

function PGPclGetPrefStringAlloc(PGPPref: pPGPPref; PrefIndex: PGPPrefIndex; var Str: PChar): PGPError;
begin
  if PGP7X then
    Result:=PGPclGetPrefStringAlloc7(PGPPref, PrefIndex, Str)
  else Result:=PGPclGetPrefStringAlloc6(PGPPref, PrefIndex, Str);
end;

function PGPclGetPrefStringBuffer(PGPPref: pPGPPref; PrefIndex: PGPPrefIndex; MaxSize: PGPSize; Str: PChar): PGPError;
begin
  if PGP7X then
    Result:=PGPclGetPrefStringBuffer7(PGPPref, PrefIndex, MaxSize, Str)
  else Result:=PGPclGetPrefStringBuffer6(PGPPref, PrefIndex, MaxSize, Str);
end;

function PGPclSetPrefString(PGPPref: pPGPPref; PrefIndex: PGPPrefIndex; Str: PChar): PGPError;
begin
  if PGP7X then
    Result:=PGPclSetPrefString7(PGPPref, PrefIndex, Str)
  else Result:=PGPclSetPrefString6(PGPPref, PrefIndex, Str);
end;

function PGPclGetPrefData(PGPPref: pPGPPref; PrefIndex: PGPPrefIndex;
			  var DataLength: PGPSize; var InBuffer: Pointer): PGPError;
begin
  if PGP7X then
    Result:=PGPclGetPrefData7(PGPPref, PrefIndex, DataLength, InBuffer)
  else Result:=PGPclGetPrefData6(PGPPref, PrefIndex, DataLength, InBuffer);
end;

function PGPclSetPrefData(PGPPref: pPGPPref; PrefIndex: PGPPrefIndex;
			  DataLength: PGPSize; OutBuffer: Pointer): PGPError;
begin
  if PGP7X then
    Result:=PGPclSetPrefData7(PGPPref, PrefIndex, DataLength, OutBuffer)
  else Result:=PGPclSetPrefData6(PGPPref, PrefIndex, DataLength, OutBuffer);
end;

function PGPclRemovePref(PGPPref: pPGPPref; PrefIndex: PGPPrefIndex): PGPError;
begin
  if PGP7X then
    Result:=PGPclRemovePref7(PGPPref, PrefIndex)
  else Result:=PGPclRemovePref6(PGPPref, PrefIndex);
end;

function PGPclOpenClientPrefs(MemMgr: pPGPMemoryMgr; var PGPPref: pPGPPref): PGPError;
begin
  if PGP7X then
    Result:=PGPclOpenClientPrefs7(MemMgr, PGPPref)
  else Result:=PGPclOpenClientPrefs6(MemMgr, PGPPref);
end;

function PGPclCloseClientPrefs(PGPPref: pPGPPref; bSave: Longbool): PGPError;
begin
  if PGP7X then
    Result:=PGPclCloseClientPrefs7(PGPPref, bSave)
  else Result:=PGPclCloseClientPrefs6(PGPPref, bSave);
end;

procedure PGPclNotifyPrefsChanges(lParam: Longint);
begin
  if PGP7X then
    PGPclNotifyPrefsChanges7(lParam)
  else PGPclNotifyPrefsChanges6(lParam);
end;

procedure PGPclNotifyKeyringChanges(lParam: Longint);
begin
  if PGP7X then
    PGPclNotifyKeyringChanges7(InitFlags, lParam)
  else PGPclNotifyKeyringChanges6(lParam);
end;

procedure PGPclNotifyKeyserverPrefsChanges(lParam: Longint);
begin
  if PGP7X then
    PGPclNotifyKeyserverPrefsChanges7(lParam)
  else PGPclNotifyKeyserverPrefsChanges6(lParam);
end;

function PGPclSelectKeys(Context: pPGPContext;
			 tlsContext: pPGPtlsContext;
			 hWndParent: Longint;
			 pszPrompt: PChar;
			 KeySetToDisplay: pPGPKeySet;
			 KeySetMain: pPGPKeySet;
			 Flags: Longint;
			 var KeySetSelected: pPGPKeySet): PGPError;
begin
  if PGP7X then begin
    Result:=PGPclSelectKeysEx7(Context, tlsContext, hWndParent, pszPrompt,
			       KeySetToDisplay, Flags, KeySetSelected);
  end
  else begin
    Result:=PGPclSelectKeysEx6(Context, tlsContext, hWndParent, pszPrompt,
			       KeySetToDisplay, KeySetMain, Flags, KeySetSelected);
  end;
end;

function PGPGetKeyServerPrefs(Pref: pPGPPref;
			      var KeyServerList: pPGPKeyServerEntry;
			      var KeyServerCount: PGPUInt32): PGPError;
var
  DataLength: PGPSize;
begin
  if PGP7X then
    Result:=PGPclGetPrefData7(Pref, kPGPPrefKeyServerList, DataLength, pointer(KeyServerList))
  else Result:=PGPclGetPrefData6(Pref, kPGPPrefKeyServerList, DataLength, pointer(KeyServerList));
  KeyServerCount:=DataLength div SizeOf(TPGPKeyServerEntry);
end;

function PGPSetKeyServerPrefs(Pref: pPGPPref;
			      KeyServerList: pPGPKeyServerEntry;
			      KeyServerCount: PGPUInt32): PGPError;
var
  DataLength: PGPSize;
begin
  DataLength:=KeyServerCount * SizeOf(TPGPKeyServerEntry);
  if PGP7X then
    Result:=PGPclSetPrefData7(Pref, kPGPPrefKeyServerList, DataLength, pointer(KeyServerList))
  else Result:=PGPclSetPrefData6(Pref, kPGPPrefKeyServerList, DataLength, pointer(KeyServerList));
end;

initialization

  if PGPInitErrorCode=ieNone then begin
    if PGP7X then begin
      PGPclInitLibrary7:=GetProcAddress(hPGPclLib, '_PGPclInitLibrary@8');
      PGPclCloseLibrary7:=GetProcAddress(hPGPclLib, '_PGPclCloseLibrary@0');
      PGPclPreferences7:=GetProcAddress(hPGPclLib, '_PGPclPreferences@16');
      PGPclGetPrefBoolean7:=GetProcAddress(hPGPclLib, '_PGPclGetPrefBoolean@12');
      PGPclSetPrefBoolean7:=GetProcAddress(hPGPclLib, '_PGPclSetPrefBoolean@12');
      PGPclGetPrefNumber7:=GetProcAddress(hPGPclLib, '_PGPclGetPrefNumber@12');
      PGPclSetPrefNumber7:=GetProcAddress(hPGPclLib, '_PGPclSetPrefNumber@12');
      PGPclGetPrefStringAlloc7:=GetProcAddress(hPGPclLib, '_PGPclGetPrefStringAlloc@12');
      PGPclGetPrefStringBuffer7:=GetProcAddress(hPGPclLib, '_PGPclGetPrefStringBuffer@16');
      PGPclSetPrefString7:=GetProcAddress(hPGPclLib, '_PGPclSetPrefString@12');
      PGPclGetPrefData7:=GetProcAddress(hPGPclLib, '_PGPclGetPrefData@16');
      PGPclSetPrefData7:=GetProcAddress(hPGPclLib, '_PGPclSetPrefData@16');
      PGPclRemovePref7:=GetProcAddress(hPGPclLib, '_PGPclRemovePref@8');
      PGPclOpenClientPrefs7:=GetProcAddress(hPGPclLib, '_PGPclPeekClientLibPrefRefs@8');
      PGPclCloseClientPrefs7:=GetProcAddress(hPGPclLib, '_PGPclFlushClientLibPrefs@8');
      PGPclNotifyPrefsChanges7:=GetProcAddress(hPGPclLib, '_PGPclNotifyPrefsChanges@4');
      PGPclNotifyKeyringChanges7:=GetProcAddress(hPGPclLib, '_PGPclNotifyKeyringChanges@8');
      PGPclNotifyKeyserverPrefsChanges7:=GetProcAddress(hPGPclLib, '_PGPclNotifyKeyserverPrefsChanges@4');
      PGPclSelectKeysEx7:=GetProcAddress(hPGPclLib, '_PGPclSelectKeys@28');
      WM_PGPReloadPrefs:=RegisterWindowMessage(RELOADPREFSMSG7);
      WM_PGPReloadKeyring:=RegisterWindowMessage(RELOADKEYRINGMSG7);
      WM_PGPReloadKeyserverPrefs:=RegisterWindowMessage(RELOADKEYSERVERPREFSMSG7);
    end
    else begin
      PGPclInitLibrary6:=GetProcAddress(hPGPclLib, 'PGPclInitLibrary');
      PGPclCloseLibrary6:=GetProcAddress(hPGPclLib, 'PGPclCloseLibrary');
      PGPclPreferences6:=GetProcAddress(hPGPclLib, 'PGPclPreferences');
      PGPclGetPrefBoolean6:=GetProcAddress(hPGPclLib, 'PGPclGetPrefBoolean');
      PGPclSetPrefBoolean6:=GetProcAddress(hPGPclLib, 'PGPclSetPrefBoolean');
      PGPclGetPrefNumber6:=GetProcAddress(hPGPclLib, 'PGPclGetPrefNumber');
      PGPclSetPrefNumber6:=GetProcAddress(hPGPclLib, 'PGPclSetPrefNumber');
      PGPclGetPrefStringAlloc6:=GetProcAddress(hPGPclLib, 'PGPclGetPrefStringAlloc');
      PGPclGetPrefStringBuffer6:=GetProcAddress(hPGPclLib, 'PGPclGetPrefStringBuffer');
      PGPclSetPrefString6:=GetProcAddress(hPGPclLib, 'PGPclSetPrefString');
      PGPclGetPrefData6:=GetProcAddress(hPGPclLib, 'PGPclGetPrefData');
      PGPclSetPrefData6:=GetProcAddress(hPGPclLib, 'PGPclSetPrefData');
      PGPclRemovePref6:=GetProcAddress(hPGPclLib, 'PGPclRemovePref');
      PGPclOpenClientPrefs6:=GetProcAddress(hPGPclLib, 'PGPclOpenClientPrefs');
      PGPclCloseClientPrefs6:=GetProcAddress(hPGPclLib, 'PGPclCloseClientPrefs');
      PGPclNotifyPrefsChanges6:=GetProcAddress(hPGPclLib, 'PGPclNotifyPrefsChanges');
      PGPclNotifyKeyringChanges6:=GetProcAddress(hPGPclLib, 'PGPclNotifyKeyringChanges');
      PGPclNotifyKeyserverPrefsChanges6:=GetProcAddress(hPGPclLib, 'PGPclNotifyKeyserverPrefsChanges');
      PGPclSelectKeysEx6:=GetProcAddress(hPGPclLib, 'PGPclSelectKeysEx');
      WM_PGPReloadPrefs:=RegisterWindowMessage(RELOADPREFSMSG6);
      WM_PGPReloadKeyring:=RegisterWindowMessage(RELOADKEYRINGMSG6);
      WM_PGPReloadKeyserverPrefs:=RegisterWindowMessage(RELOADKEYSERVERPREFSMSG6);
    end;
  end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -