[Release] C++ VL64 and B64 encoding functions

Status
Not open for further replies.

Adil

DevBest CEO
May 28, 2011
1,278
718
This probably won't be of use to those of you who've moved onto the new crypto, but oh well.
Pretty self explanatory, it's a stable port of the VL64 and B64 encoding functions written by Jeax (I believe) and Jordan (his Java port provided the basis for this).
VL64 function
PHP:
static string Encode_VL64(int i){
string s = "";
char res[6]; //assign the var res to a a char array - len6
  int p = 0; 
 int sP = 0;
 int bytes = 1;
 int negativeMask = i >= 0 ? 0 : 4; //? : = if else clause
 i = abs(i);
 res[p++] = (char)(64 +(i & 3));
 for (i >>= 2; i != 0; i >>= 6){
 bytes++;
 res[p++] = (char)(64 + (i & 0x3f));
 }
 int null = 0;
 res[sP] = (char)(res[sP] | bytes << 3 | negativeMask);
  string tmp =  string(res);
tmp.erase(2,22); //clever little method to cut the string. 
//If this was not done, the output would have extremely weird chars.
  return tmp;
}
B64 function
PHP:
static string Encode_B64(int i){
string s = "";
 for (int x = 1; x <= 2; x++){
                s += (char)((char)(64 + (i >> 6 * (2 - x) & 0x3f)));
}
 return s;
}
Usage:
PHP:
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main()
{
int value;
cout << "Enter your value\n";
cin >> value;
cout << //either: Encode_B64(value) or Encode_VL64(value);
cin.get()
return 0;
}
Compiled binary, VS solution and source code:

Pictures of it functioning:
ZUap2.png

DmCOz.png

Notes:
Don't go off releasing this under your name.
Option 3 will output "coming soon", due to native C++ not having certain classes and functions built-in.
Report any bugs here. (If you enter a string for menu selection, prepare for errors).
~Adil


[Please don't infract me. I've seen plenty of other people bumping their threads/double posting with updates.]
Notes:
Updated build. Latest can be found at the same directory,

Updates:
-RC4 has been implemented. If you wish to encrypt something with RC4, please change:
Code:
rc4.Encrypt(key, "NV6VVFPoC7FLDlzDUri3qcOAg9cRoFOmsYR9ffDGy5P8HfF6eekX40SFSVfJ1mDb3lcpYRqdg28sp61eHkPukKbqTu1JsVEKiRavi04YtSzUsLXaYSa5BEGwg5G2OF");
to:
Code:
rc4.Encrypt(key, "your special key here");
The key variable is user input.

Problems:
-Dom has told me that my encryption is static, whereas the habbo rc4 encryption wasn't. You can use this for static RC4 encryption if you wish.

Images:
16TLs.png


Credits:
for his RC4.h file :D
~Adil
 
Status
Not open for further replies.

Users who are viewing this thread

Top