本文整理汇总了C++中Crypto::Encrypt方法的典型用法代码示例。如果您正苦于以下问题:C++ Crypto::Encrypt方法的具体用法?C++ Crypto::Encrypt怎么用?C++ Crypto::Encrypt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Crypto
的用法示例。
在下文中一共展示了Crypto::Encrypt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestEncryptDecrypt
static int TestEncryptDecrypt(const Crypto& cryptoA, const Crypto& cryptoB)
{
std::string content= cryptoA.GeneratePassword(std::string("0123456789abcdefghijklmnopqrstuvABCDEFGHIJKLMNOPQRSTUVWXYZ"), 256000);
auto encrypted = cryptoA.Encrypt(std::vector<BYTE>(content.begin(), content.end()), true);
auto decrypted = cryptoB.Decrypt(encrypted, true);
auto sameCount = 0;
for (auto index = 0 ; index != content.length() ; ++index)
{
sameCount += content[index] == encrypted[index] ? 1 : 0;
if (content[index] != decrypted[index])
{
std::wcout << L"Crypto::Encrypt decrypted content error" << std::endl;
return 1;
}
}
if (sameCount == content.length())
{
std::wcout << L"Crypto::Encrypt encrypted content error" << std::endl;
return 1;
}
return 0;
}
示例2: sizeof
// Our thread to handle sending packets
void *send_thread( void *arg ) {
// Set up misc variables and the xenimus server info
int s = *(int*) arg;
int ret;
struct sockaddr_in si_xen;
memset((char *) &si_xen, 0, sizeof(si_xen));
si_xen.sin_family = AF_INET;
si_xen.sin_port = htons( 5050 );
if( inet_aton( "64.34.163.8" , &si_xen.sin_addr ) == 0 ) {
printf( "inet_aton() failed\n" );
return 0;
}
Crypto crypto;
// Make sure we are always running
while( !exit_bot ) {
// Check if there are any packets waiting in the queue
if( !send_queue.empty() ) {
// Grab the top packet
Packet tmp = send_queue.front();
//printf( "sending packet: " );
//for( int i = 0; i < tmp.length(); i++ ) {
// printf( "%02X ", tmp[ i ] );
//}
//printf( "\n" );
// Encrypt it for sending
crypto.Encrypt( tmp, tmp.length() );
// Send the packet
ret = sendto( s, tmp, tmp.length(), 0, (struct sockaddr*)&si_xen, sizeof( si_xen ));
if( ret == -1 ) {
printf( "failed to send last packet\n" );
}
// Remove the top packet from queue
send_queue.pop();
}
// Take a quick breather
SLEEP( 10 );
}
return 0;
}