【发布时间】:2013-10-11 15:48:57
【问题描述】:
我正在使用一个我非常喜欢的课程:
#pragma once
#include "StdAfx.h"
#include "xorcipher.h"
#include <vector>
using namespace std;
typedef unsigned __int8 BYTE;
vector<BYTE>m_Key;
CXORcipher::CXORcipher()
{
m_Key.push_back(0x55);
m_Key.push_back(0xae);
m_Key.push_back(0x8c);
m_Key.push_back(0x14);
}
CXORcipher::~CXORcipher()
{
}
vector<BYTE> xor_encryptdecrypt(const vector<BYTE>&uInput)
{
vector<BYTE> ret;
ret.reserve(uInput.size());
vector<BYTE>::const_iterator keyIterator = m_Key.begin();
for(vector<BYTE>::const_iterator inputIterator = uInput.begin(); inputIterator != uInput.end(); ++ inputIterator)
{
ret.push_back(*inputIterator ^ *keyIterator);
// advance the key iterator, wrapping to begin.
if(++ keyIterator == m_Key.end())
{
keyIterator = m_Key.begin();
}
}
return ret;
}
但是,我想提供一个 unsigned char 向量而不是 typedef。 我对 C++ 还不是很坚定,我害怕把事情搞砸。
有人能告诉我我能做什么吗?
谢谢!
【问题讨论】:
-
我不明白:
vector<BYTE>已经是vector<unsigned char>。你能澄清你的问题吗? -
typedef是“弱”的。如果您将typedefA用作B,则可以交替使用A和B。
标签: c++ class typedef encryption