KDevelop hangs if I include this file in a project

john.allen at orbiscard.com john.allen at orbiscard.com
Thu Nov 25 11:44:08 GMT 1999



--
===============================================================================
John Allen,                                    Email:  john.allen at orbiscard.com
Orbis Payment Technology Ltd,                  Phone:  +353-1-2945111
3 Sandyford Park,                              Mobile: +353-86-2315986
Sandyford Industrial Estate,                   Fax:    +353-1-2945119
Dublin 18.
===============================================================================


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop/attachments/19991125/a789f2ae/attachment.html>
-------------- next part --------------
//-------------------------------------oOo--------------------------------------
// This file is part of the VP Toolkit
// Copyright (C) 1999 John Allen
// Copyright (C) 1999 Orbis Payment Technology.
//
// This library is free software; it is released under the terms of the
// GNU LGPL v2 or later.
//
// $Id: vpencrypt.cpp,v 1.5 1999/10/19 14:51:22 jallen Exp $
//-------------------------------------oOo--------------------------------------

#include <vpencrypt.hpp>

#if defined(HAVE_IOMANIP)
#include <iomanip>
#elif defined(HAVE_IOMANIP_H)
#include <iomanip.h>
#endif

VPNAMESPACE_BEGIN(vptk)

#if defined(USE_NAMESPACE_STD)
using namespace std;
#endif

SimpleEncryptionEngine::Key SimpleEncryptionEngine::cMasterKey =
{
    0x51, 0x52, 0x55, 0x54, 0x59, 0x56, 0x5D, 0x58, 0x61, 0x5A, 0x5C, 0x5C, 0x60, 0x5E, 0x64, 0x60,
    0x43, 0x42, 0x47, 0x44, 0x4B, 0x46, 0x4F, 0x48, 0x4A, 0x4A, 0x4E, 0x4C, 0x52, 0x4E, 0x56, 0x50,
    0x27, 0x22, 0x2B, 0x24, 0x26, 0x26, 0x2A, 0x28, 0x2E, 0x2A, 0x32, 0x2C, 0x2D, 0x2E, 0x31, 0x30,
    0x76, 0x72, 0x7A, 0x74, 0x75, 0x76, 0x79, 0x78, 0x7D, 0x7A, 0x81, 0x7C, 0x85, 0x7E, 0x80, 0x80,
    0x35, 0x32, 0x39, 0x34, 0x3D, 0x36, 0x38, 0x38, 0x3C, 0x3A, 0x40, 0x3C, 0x44, 0x3E, 0x3F, 0x40,
    0x02, 0x02, 0x06, 0x04, 0x0A, 0x06, 0x0E, 0x08, 0x09, 0x0A, 0x0D, 0x0C, 0x11, 0x0E, 0x15, 0x10,
    0x68, 0x62, 0x63, 0x64, 0x67, 0x66, 0x6B, 0x68, 0x6F, 0x6A, 0x73, 0x6C, 0x6E, 0x6E, 0x72, 0x70,
    0x19, 0x12, 0x14, 0x14, 0x18, 0x16, 0x1C, 0x18, 0x20, 0x1A, 0x1B, 0x1C, 0x1F, 0x1E, 0x23, 0x20,
};

/**
 * CreateKey
 * This method creates an internal key used for encryption,
 * this generated key is based on the key the user entered.
 */
void SimpleEncryptionEngine::CreateKey(
	const char* userKey,
	Key& key)
{
    const char* pUserKey = userKey;

	for (int i=0; i < sizeof(Key); i++)
	{
		key[i] = (unsigned char)cMasterKey[i] ^ (unsigned char)*pUserKey++;
		
		if (!*pUserKey)
		{
			pUserKey = userKey;
		}
	}
}

void SimpleEncryptionEngine::Encrypt(unsigned char* data, const char* key, int length)
{
    try
    {
    	Key ekey;
    	
		CreateKey(key, ekey);
		
		for (int i=0, j=0; i < length; i++, data++)
		{
			*data = (*data) ^ ekey[j++];
			
			if (j == sizeof(Key))
			{
				j = 0;
			}
		}
    	
    }
    catch (...)
    {
        throw;
    }
}

void SimpleEncryptionEngine::Decrypt(unsigned char* data, const char* key, int length)
{
    try
    {
    	Encrypt(data, key, length);
    }
    catch (...)
    {
        throw;
    }
}

/**
 *
 */
Binder<Encryptor> Encryptor::New(const string& passPhrase, Engine engine)
{
    try
    {
        return Binder<Encryptor>(new Encryptor(passPhrase, engine));
    }
    catch (...)
    {
        throw;
    }
}

/**
 *
 */
Encryptor::Encryptor(const string& passPhrase, Engine engine):
	iPassPhrase(passPhrase)
{
	switch (engine)
	{
        case RC4:
        {
        }
        break;

        case RC5:
        {
        }
        break;

        case IDEA:
        {
        }
        break;

        case VPE:
		default:
		{
        	iEngine = Binder<EncryptionEngine>(new SimpleEncryptionEngine);
		}
        break;
	}
}

/**
 *
 */
void Encryptor::Encrypt(char* data, int length)
{
	if (iEngine.IsBound())
	{
		iEngine->Encrypt((unsigned char*)data, iPassPhrase.c_str(), length);
	}
}

/**
 *
 */
void Encryptor::Decrypt(char* data, int length)
{
	if (iEngine.IsBound())
	{
		iEngine->Decrypt((unsigned char*)data, iPassPhrase.c_str(), length);
	}
}

VPNAMESPACE_END(vptk)

//-------------------------------------oOo--------------------------------------












More information about the KDevelop mailing list