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

📄 keyfile.cpp

📁 HDCP Key加密程序
💻 CPP
字号:
// KeyFile.cpp: implementation of the CKeyFile class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "PWKeyEncrypt.h"
#include "KeyFile.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CKeyFile::CKeyFile()
{

}

CKeyFile::~CKeyFile()
{

}

BOOL CKeyFile::Exists()
{
   CFileFind	find;
   return find.FindFile( m_strFileName );
}

BOOL CKeyFile::GetNumberOfKeys(unsigned long &nKeys)
{
	CFileStatus fs;
	CFile::GetStatus(m_strFileName, fs);
	if (fs.m_attribute & 0x01A)
	{
		return FALSE;
	}

	CFile fp;
	fp.Open(m_strFileName, CFile::modeRead);
	
	unsigned long nSize = fp.GetLength();
	
	//
	// Start off assuming zero keys...
	//
	nKeys = 0;

	if (nSize > 0)
	{
		//
		// Ignore the 4-byte "Order Format" code.
		//
		nSize -= ORDER_FORMAT_SIZE;

		//
		// Make sure the remainder of the file is a size divisible
		// by 308 bytes.
		//
		if (nSize % KEYSET_DATA_SIZE == 0)
		{
			nKeys = nSize / KEYSET_DATA_SIZE;
			return TRUE;
		}
	}

	return FALSE;
}

BOOL CKeyFile::LoadKeyData(unsigned long nKey, CKeySet* pKeySet)
{
	int nSeekPos = ORDER_FORMAT_SIZE + (KEYSET_DATA_SIZE * nKey);

	CFile keyfile;
	
	if (!keyfile.Open(m_strFileName, CFile::modeRead))
	{
		//
		// Couldn't open the key file...
		//
		return FALSE;
	}

	keyfile.Seek(nSeekPos, CFile::begin);

	keyfile.Read(pKeySet->RawData, KEYSET_DATA_SIZE);

	return TRUE;
}

⌨️ 快捷键说明

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