[C++]RC4 class for Habbo (I think) - Latest rev

Results 1 to 6 of 6
  1. #1
    Alpha Member Caustik is offline
    MemberRank
    May 2011 Join Date
    LondonLocation
    1,837Posts

    [C++]RC4 class for Habbo (I think) - Latest rev

    Here it is...
    Code:
    #include <iostream>
    #pragma once
    
    
    // RC4.h
    // Contains definitions for functions to be used in RC4.cpp
    typedef unsigned char byte;
    class RC4
    {
    public:
    RC4(void);
    
    ~RC4(void);
    
    void Init(byte tKey[]);
    
    void swap(int,int);
    
    void parse(byte t[]);
    
    
    private:
    int i;
    int j;
    int table[256];
    
    };
    RC4.cpp
    Code:
    #include "RC4.h"
    
    
    RC4::RC4(void)
    {
    }
    
    
    
    
    RC4::~RC4(void)
    {
    }
    
    void RC4::Init(byte *tKey)
    {
    int len = sizeof(tKey)/sizeof(byte);
    this->i = 0;
    while(this->i < 0x100)
    {
    this->table[this->i] = this->i;
    this->i++;
    }
    
    this->i=0;
    this->j=0;
    
    while(this->i < 0x100)
    {
    this->j = ((this->j + this->table[this->i]) + (tKey[this->i % len] & 0xff)) % 0x100 ;
    this->swap(this->i,this->j);
    this->i++;
    }
    
    this->i=0;
    this->j=0;
    
    
    }
    
    void RC4::swap(int a, int b)
    {
    int x = this->table[a];
    this->table[a] = this->table[b];
    this->table[b] = x;
    
    }
    
    void RC4::parse(byte *k)
    {
    int x = sizeof(k)/sizeof(byte);
    for(int a = 0; a < x; a++)
    {
    this->i = (this->i+1)%256;
    this->j = (this->j + this->table[this->i]) % 256;
    this->swap(this->i,this->j);
    k[a] = (byte)((k[a] & 0xff) ^ this->table[(this->table[this->i] + this->table[this->j]) % 256]);
    }
    }
    I have not tested it as of yet. It is a direct port of Itachi's Java release.
    Sorry for the lack of documentation, this was written quite quickly.

    Have fun!

    Usage
    Code:
    RC4 *rc4 = new RC4(); // create the rc4 variable on the heap
    rc4->init(byte[] tKey);
    rc4->parse(byte[] tKey);


  2. #2
    Developer Quackster is offline
    DeveloperRank
    Dec 2010 Join Date
    AustraliaLocation
    3,483Posts

    Re: [C++]RC4 class for Habbo (I think) - Latest rev

    Nice work Adil. Although I don't have any experience with C++ I believe this should be archived.
    Last edited by Quackster; 02-11-12 at 06:00 AM. Reason: Typed 'all though'

  3. #3
    Alpha Member Caustik is offline
    MemberRank
    May 2011 Join Date
    LondonLocation
    1,837Posts
    Quote Originally Posted by Quackster View Post
    Nice work Adil. All though I don't have any experience with C++ I believe this should be archived.
    Thanks Alex :D.
    I may also be releasing other things sikmilar to this.

  4. #4
    Account Upgraded | Title Enabled! Chapo is offline
    MemberRank
    Jul 2010 Join Date
    United StatesLocation
    944Posts

    Re: [C++]RC4 class for Habbo (I think) - Latest rev

    This looks nice, now i can begin my first emulator in C++ because i want to learn it =)

    Big like!

  5. #5
    Alpha Member Emily is offline
    MemberRank
    Oct 2012 Join Date
    The NetherlandsLocation
    2,408Posts

    Re: [C++]RC4 class for Habbo (I think) - Latest rev

    Thanks for this release.

  6. #6
    Alpha Member Caustik is offline
    MemberRank
    May 2011 Join Date
    LondonLocation
    1,837Posts
    Quote Originally Posted by Niels View Post
    This looks nice, now i can begin my first emulator in C++ because i want to learn it =)

    Big like!
    Use C or Scala.
    :)



Advertisement