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

📄 pgprndwin32.c

📁 著名的加密软件的应用于电子邮件中
💻 C
字号:
/*
* pgpRndWin32.c -- Get high-resolution timing information to seed the random
* number generator. Win32 version.
*
* Copyright (C) 1996,1997 Pretty Good Privacy, Inc. All rights reserved.
*
* $Id: pgpRndWin32.c,v 1.2.2.1 1997/06/07 09:51:36 mhw Exp $
*/

#if HAVE_CONFIG_H
#include "config.h"
#endif

#include <windows.h>

#include "pgpUsuals.h"
#include "pgpRndom.h"
#include "pgpRnd.h"

/*
* Add as much timing-dependent random noise as possible
* to the randPool. Typically, this involves reading the most
* accurate system clocks available.
*
* Returns the number of ticks that have passed since the last call,
* for entropy estimation purposes.
*/
word32
ranGetEntropy(struct PgpRandomContext const *rc)
	{
			word32 delta;
			static WORD oldms;
			static DWORD oldlow;
			LARGE_INTEGER newperf;
			SYSTEMTIME stime;

if (QueryPerformanceCounter(&newperf)) {
	pgpRandomAddBytes(rc, (byte *)&newperf, sizeof(newperf));
	delta = newperf.LowPart - oldlow;
	oldlow = newperf.LowPart;
	} else {
			GetSystemTime(&stime);
			pgpRandomAddBytes(rc, (byte *)&stime, sizeof(stime));
			delta = stime.wMilliseconds - oldms;
			oldms = stime.wMilliseconds;
			delta /= 10;	 /* crude resolution */
	}

return delta;
}

⌨️ 快捷键说明

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