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

📄 secsplit.cpp

📁 300种加密解密算法.包含RSA、SHA、MD5、RC2、RC5、RC6等等。
💻 CPP
字号:
// secsplit.cpp - written and placed in the public domain by Wei Dai

#include "pch.h"
#include "secsplit.h"
#include "queue.h"

NAMESPACE_BEGIN(CryptoPP)

void SplitFork::Put(byte inByte)
{
	SecByteBlock buf(NumberOfPorts());

	rng.GetBlock(buf, NumberOfPorts()-1);
	buf[NumberOfPorts()-1] = inByte;

	for (int i=0; i<NumberOfPorts(); i++)
	{
		AccessPort(i).Put(buf[i]);
		buf[NumberOfPorts()-1] ^= buf[i];
	}
}

void SplitFork::Put(const byte *inString, unsigned int length)
{
	SecByteBlock randomBlock(length);
	SecByteBlock lastBlock(length);

	memcpy(lastBlock, inString, length);

	for (int i=0; i<NumberOfPorts()-1; i++)
	{
		rng.GetBlock(randomBlock, length);
		AccessPort(i).Put(randomBlock, length);
		xorbuf(lastBlock, randomBlock, length);
	}

	AccessPort(NumberOfPorts()-1).Put(lastBlock, length);
}

void SplitJoin::NotifyInput(unsigned int /* interfaceId */, unsigned int /* length */)
{
	unsigned long n=AccessPort(0).MaxRetrieveable();

	for (int i=1; n && i<NumberOfPorts(); i++)
		n = STDMIN(n, AccessPort(i).MaxRetrieveable());

	if (n)
	{
		const unsigned int l = (unsigned int) n;    // convert long to int
		SecByteBlock original(l);
		SecByteBlock buf(l);

		AccessPort(NumberOfPorts()-1).Get(original, l);
		for (int i=0; i<NumberOfPorts()-1; i++)
		{
			AccessPort(i).Get(buf, l);
			xorbuf(original, buf, l);
		}
		outQueue->Put(original, l);
	}
}

NAMESPACE_END

⌨️ 快捷键说明

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