keyset.cpp

来自「HDCP Key加密程序」· C++ 代码 · 共 54 行

CPP
54
字号
// KeySet.cpp: implementation of the CKeySet class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "PWKeyEncrypt.h"
#include "KeySet.h"

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

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

CKeySet::CKeySet()
{

}

CKeySet::~CKeySet()
{

}

BOOL CKeySet::Encrypt()
{
	int nPrev = 0;

	//
	// Copy the KEY_SET_VECTOR to the encrypted data without
	// any encryption.
	//
	memcpy(EncryptedData, RawData, VECTOR_SIZE);

	for (int nByte = 0; nByte < KEYSET_SIZE; nByte ++)
	{
		EncryptedData[VECTOR_SIZE+nByte] = RawData[VECTOR_SIZE+nByte] ^ nPrev;
		nPrev = RawData[VECTOR_SIZE+nByte];

//#define SHOW_ENCRYPTION
#ifdef SHOW_ENCRYPTION
		CString strDebug;
		strDebug.Format("Encode in: 0x%02X  out: 0x%02X\n", nPrev, EncryptedData[nByte]);
		OutputDebugString(strDebug);
#endif
	}

	return TRUE;
}

⌨️ 快捷键说明

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