Post: [C++] Useful Codes (If your smart).
03-01-2011, 12:40 AM #1
kiwimoosical
Bounty hunter
(adsbygoogle = window.adsbygoogle || []).push({}); I'm bored so now every time I write or find something useful lolz.

Turn an individual bit on in some data:
    int turnBitOn(int position, int data)
{
int temp = data | (1<<position);
return temp;
}
int example = turnBitOn(4, Cool Man (aka Tustin); //24


Turn an individual bit off in some data:
    int turnBitOff(int position, int data)
{
int temp = data & ~(1<<position);
return temp;
}
int example = turnBitOff(4, 24); //8


XOR encrypt:
    typedef unsigned char* BYTEP;

bool XOREncrypt(BYTEP data, int dataLen, BYTEP key, int keyLen)
{
if(keyLen <= 0) return false;
for( unsigned int index = 0; index < dataLen; index++ )
data[index] = data[index] ^ key[index % keyLen];
return true;
}
XOREncrypt(yourData, yourDatasLength, yourSecretKey, yourSecretKeysLength);


Write to a file:
    typedef unsigned char* BYTEP;
bool Write(char* fname, BYTEP data, unsigned int dataLen, unsigned long address)
{
if(dataLen <= 0) return false;
ofstream os(fname, ios::binary);
os.seekp(ios::beg);
streamoff addresss = address;
os.seekp(addresss);
for(int x = 0; x<dataLen; ++x)
os<<data[x];
return true;
}
Write("C:\\naggers.exe", datasauce, datasaucelength, 0x69);


If you have any needs or suggestions, please post them and I'll work it out Happy

The following 2 users say thank you to kiwimoosical for this useful post:

Ritztro, TheUberFail
03-02-2011, 10:17 PM #11
kiwimoosical
Bounty hunter
Originally posted by pcfreak30 View Post
I would program in c++, I just hate memory management. Prefer interpreted languages and .NET stuff. Though I get really annoyed with JAVA.

BTW, TTG_Dutch, I added you on skype Smile.


Java does get annoying depending on your IDE Smile
Use JCreator, Eclipse sucks. Sadly it is the best (only, rather than text editors and command line shit) for Android developement.
03-02-2011, 11:16 PM #12
Ritztro
I am a Game Developer
Originally posted by kiwimoosical View Post
Java does get annoying depending on your IDE Smile
Use JCreator, Eclipse sucks. Sadly it is the best (only, rather than text editors and command line shit) for Android developement.


Hey do you mind giving me a link to those cs classes you took online? Im sorry I havent been on AIM. I have a big project due friday and I procrastinated so I have a lot of work to do. Right now when I am messaging you, I am on a school computer, so no aim..

---------- Post added at 03:16 PM ---------- Previous post was at 03:15 PM ----------

Originally posted by pcfreak30 View Post
I would program in c++, I just hate memory management. Prefer interpreted languages and .NET stuff. Though I get really annoyed with JAVA.

BTW, TTG_Dutch, I added you on skype Smile.


Sorry but its TTT_Dutch lol. TTT = TheTechTouch (my company)

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo