Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <math.h>
- #include <fstream>
- #include <cstdlib>
- #include "RC4.h"
- using namespace std;
- int pTx = 0;
- int seed = 0;
- int PaddingGenerator(int ptx, int seed)
- {
- pTx = ptx;
- seed = seed;
- return pTx,seed;
- }
- int iterateRandom()
- {
- int newPtx = abs(19979 * pTx + 5) %seed;
- pTx = newPtx;
- return newPtx;
- }
- 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);
- return tmp;
- }
- 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;
- }
- static int Decode_B64(string strVal){
- int intTot = 0;
- int y = 0;
- for (int x = (strVal.length() - 1); x >= 0; x--) {
- int intTmp = (int) (char) ((strVal.at(x) - 64));
- if (y > 0) {
- intTmp = intTmp * pow(64.0, y);
- }
- intTot += intTmp;
- y++;
- }
- return intTot;
- }
- static int Decode_VL64(string raw){
- int pos = 0;
- int v = 0;
- bool negative = (raw[pos] & 4) == 4;
- int totalBytes = raw[pos] >> 3 & 7;
- v = raw[pos] & 3;
- pos++;
- int shiftAmount = 2;
- for (int b = 1; b < totalBytes; b++)
- {
- v |= (raw[pos] & 0x3f) << shiftAmount;
- shiftAmount = 2 + 6 * b;
- pos++;
- }
- if (negative)
- v *= -1;
- return v;
- }
- string Decode_Short(unsigned int v){
- string t;
- t += (unsigned char)((v >> 8) & 0xFF);
- t += (unsigned char)((v >> 0) & 0xFF);
- cout << ((v >> 24) & 0xFF);
- cout << ((v >> 16) & 0xFF);
- cout << ((v >> 8) & 0xFF);
- cout << ((v >> 0) & 0xFF);
- return t;
- }
- int convertInt(int ch1, int ch2, int ch3, int ch4) {
- if ((ch1 | ch2 | ch3 | ch4) < 0)
- return -1;
- return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
- }
- int convertShort(int ch1, int ch2) {
- if ((ch1 | ch2) < 0)
- return -1;
- return ((ch1 << 8) + (ch2 << 0));
- }
- int convertToInt(string datum){
- int p = 256;
- int n = rand();
- int IntString = atoi(datum.c_str());
- IntString = IntString*pow(p,n);
- }
Advertisement
Add Comment
Please, Sign In to add comment