Exemple #1
0
bool CMyPlug::importTerrainData(iSceneData * pSceneData, const std::string& strFilename)
{
	pSceneData->clear();
	if (pSceneData->resize(253,253))
	{
		// EncTerrain
		IOReadBase* pRead = IOReadBase::autoOpen(strFilename);
		if (pRead)
		{
			if (MAP_FILE_SIZE==pRead->GetSize())
			{
				char buffer[MAP_FILE_SIZE];
				pRead->Read(buffer,MAP_FILE_SIZE);
				decrypt(buffer,MAP_FILE_SIZE);
				char* p = buffer;
				unsigned short uMuFlgMap = *((unsigned short*)p);
				p+=2;
				for (int y=0; y<253; ++y)
				{
					for (int x=0; x<253; ++x)
					{
						pSceneData->setCellTileID(x,y,*p,0);
						p++;
					}
					p+=3;
				}
				p+=256*3;
				for (int y=0; y<253; ++y)
				{
					for (int x=0; x<253; ++x)
					{
						pSceneData->setCellTileID(x,y,*p,1);
						p++;
					}
					p+=3;
				}
				p+=256*3;
				for (int y=0; y<254; ++y)
				{
					for (int x=0; x<254; ++x)
					{
						pSceneData->setVertexColor(x,y,Color32(*p,255,255,255));
						p++;
					}
					p+=2;
				}
			}
			IOReadBase::autoClose(pRead);
		}
		// EncTerrain.att
		pRead = IOReadBase::autoOpen(ChangeExtension(strFilename,".att"));
		if (pRead)
		{
			if (ATT_FILE_129KB_SIZE==pRead->GetSize())
			{
				char buffer[ATT_FILE_129KB_SIZE];
				pRead->Read(buffer,ATT_FILE_129KB_SIZE);
				decrypt(buffer,ATT_FILE_129KB_SIZE);
				decrypt2(buffer,ATT_FILE_129KB_SIZE);
				char* p = buffer;
				unsigned long uMuFlgAtt = *((unsigned long*)p);
				p+=4;
				for (int y=0; y<253; ++y)
				{
					for (int x=0; x<253; ++x)
					{
						pSceneData->setCellAttribute(x,y,*p);
						p+=2;
					}
					p+=6;
				}
			}
			else if (ATT_FILE_65KB_SIZE==pRead->GetSize())
			{
				char buffer[ATT_FILE_65KB_SIZE];
				pRead->Read(buffer,ATT_FILE_65KB_SIZE);
				decrypt(buffer,ATT_FILE_65KB_SIZE);
				decrypt2(buffer,ATT_FILE_65KB_SIZE);
				char* p = buffer;
				unsigned long uMuFlgAtt = *((unsigned long*)p);
				p+=4;
				for (int y=0; y<253; ++y)
				{
					for (int x=0; x<253; ++x)
					{
						pSceneData->setCellAttribute(x,y,*p);
						p++;
					}
					p+=3;
				}
			}
			IOReadBase::autoClose(pRead);
		}
		// TerrainHeight
		std::string strHeightFilename = GetParentPath(strFilename)+"TerrainHeight.ozb";
		pRead = IOReadBase::autoOpen(strHeightFilename);
		if (pRead)
		{
			if (HEIGHT_HEAD_SIZE+HEIGHT_BUFFER_SIZE<=pRead->GetSize())
			{
				pRead->Move(HEIGHT_HEAD_SIZE);
				for (int y=0; y<254; ++y)
				{
					pRead->Move(2);
					for (int x=0; x<254; ++x)
					{
						unsigned char uVal;
						pRead->Read(&uVal,1);
						pSceneData->setVertexHeight(x,y,uVal*0.015f);
					}
				}
			}
			IOReadBase::autoClose(pRead);
		}
	}
	return true;
}
Exemple #2
0
int decrypt_string2user(unsigned char *source, unsigned char *dest)
{
    return decrypt2(source, dest, cbc_user);
}
Exemple #3
0
int main()
{
    printf("Welcome to protectit!\n");
    printf("Please enter filename(FILENAME.txt)\n");
    char* filename = GetString();
    printf("Please enter output file name\n");
    char* output = GetString();
    printf("Would you like to use numbers or strings to encrypt?\n");
    char* type = GetString();
    char* numbers = "numbers";
    char* strings = "strings";
    if(strcmp(type, numbers) == 0)
    {
        printf("Please enter the Encryption/Decryption Key(A Number)\n");
        int key = GetInt();
        printf("Please input 1 for Encryption or 2 for Decryption\n");
        int mode = GetInt();
        //Check for Mode
        if(mode == 1)
        {
            //Start Encryption
                printf("Encrypting.......\n");
            encrypt2(key, filename, output);
            printf("Done encrypting, Please check outfile.txt :)\n");
        }
        else if(mode == 2)
        {
            //Start Decryption
            printf("Decrypting.......\n");
            decrypt2(key, filename, output);
            printf("Done decrypting, Please check outfile.txt :)\n");
          }
          else
          {
          //Yell at user
          printf("Sorry input must either be 1 or 2");
          }

    }
    else if(strcmp(type, strings) == 0)
    {
        printf("Please enter the Encryption/Decryption Key(A Letter or a Word)\n");
        char* key = GetString();
        int klen = strlen(key); //Key length variable
        for(int i = 0; i < klen; i++)
        {
            if(isalpha(key[i]))
            tolower(key[i]);
        }
        printf("Please input 1 for Encryption or 2 for Decryption\n");
        int mode = GetInt();
        //Check for Mode
        if(mode == 1)
        {
            //Start Encryption
            printf("Encrypting.......\n");
            encrypt(key, filename, output);
            printf("Done encrypting, Please check outfile.txt :)\n");
        }
        else if(mode == 2)
        {
            //Start Decryption
            printf("Decrypting.......\n");
            decrypt(key, filename, output);
            printf("Done decrypting, Please check outfile.txt :)\n");
        }
        else
        {
            //Yell at user
            printf("Sorry input must either be 1 or 2");
        }

    }
    else
    {
    //User didn't input (Numbers or Strings)
    printf("Error you should specify either numbers or strings\n");
    return 1;
    }
}
Exemple #4
0
int decrypt_string2(unsigned char *source, unsigned char *dest)
{
    return decrypt2(source, dest, cbc_key3);
}