Adilol

xmr

Dec 30th, 2011
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.69 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <string>
  4. #include <math.h>
  5. #include <fstream>
  6. #include <cstdlib>
  7. #include "RC4.h"
  8. using namespace std;
  9.  int pTx = 0;
  10.   int seed = 0;
  11.  
  12. int PaddingGenerator(int ptx, int seed)
  13.         {
  14.          pTx = ptx;
  15.         seed = seed;
  16.         return pTx,seed;
  17.         }
  18.  
  19.  int iterateRandom()
  20.         {
  21.             int newPtx = abs(19979 * pTx + 5) %seed;
  22.             pTx = newPtx;
  23.  
  24.             return newPtx;
  25.         }
  26.  
  27. static string Encode_VL64(int i){
  28.     string s = "";
  29.     char res[6]; //assign the var res to a a char array - len6
  30.       int p = 0;
  31.  int sP = 0;
  32.  int bytes = 1;
  33.  int negativeMask = i >= 0 ? 0 : 4; //? : = if else clause
  34.  i = abs(i);
  35.  res[p++] = (char)(64 +(i & 3));
  36.  for (i >>= 2; i != 0; i >>= 6){
  37.      bytes++;
  38.      res[p++] = (char)(64 + (i & 0x3f));
  39.  }
  40.  int null = 0;
  41.  res[sP] = (char)(res[sP] | bytes << 3 | negativeMask);
  42.   string tmp =  string(res);
  43. tmp.erase(2,22);
  44.   return tmp;
  45.  
  46. }
  47. static string Encode_B64(int i){
  48. string s = "";
  49.  for (int x = 1; x <= 2; x++){
  50.                 s += (char)((char)(64 + (i >> 6 * (2 - x) & 0x3f)));
  51. }
  52.  return s;
  53. }
  54. static int Decode_B64(string strVal){
  55.  
  56.     int intTot = 0;
  57.     int y = 0;
  58.     for (int x = (strVal.length() - 1); x >= 0; x--) {
  59.         int intTmp = (int) (char) ((strVal.at(x) - 64));
  60.         if (y > 0) {
  61.             intTmp = intTmp * pow(64.0,  y);
  62.         }
  63.         intTot += intTmp;
  64.         y++;
  65.     }
  66.     return intTot;
  67. }
  68. static int Decode_VL64(string raw){
  69.     int pos = 0;
  70.     int v = 0;
  71.     bool negative =  (raw[pos] & 4) == 4;
  72.      int totalBytes = raw[pos] >> 3 & 7;
  73.                 v = raw[pos] & 3;
  74.                 pos++;
  75.                 int shiftAmount = 2;
  76.                 for (int b = 1; b < totalBytes; b++)
  77.                 {
  78.                     v |= (raw[pos] & 0x3f) << shiftAmount;
  79.                     shiftAmount = 2 + 6 * b;
  80.                     pos++;
  81.                 }
  82.  
  83.                 if (negative)
  84.                     v *= -1;
  85.  
  86.                 return v;
  87. }
  88. string Decode_Short(unsigned int v){
  89. string t;
  90.  
  91.     t += (unsigned char)((v >>  8) & 0xFF);
  92.     t += (unsigned char)((v >>  0) & 0xFF);
  93. cout << ((v >> 24) & 0xFF);
  94. cout << ((v >> 16) & 0xFF);
  95. cout << ((v >>  8) & 0xFF);
  96. cout << ((v >>  0) & 0xFF);
  97. return t;
  98. }
  99.  
  100. int convertInt(int ch1, int ch2, int ch3, int ch4) {
  101.    
  102.     if ((ch1 | ch2 | ch3 | ch4) < 0)
  103.         return -1;
  104.     return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
  105.  
  106. }
  107. int convertShort(int ch1, int ch2) {
  108.  
  109.     if ((ch1 | ch2) < 0)
  110.         return -1;
  111.     return ((ch1 << 8) + (ch2 << 0));
  112. }
  113.  
  114. int convertToInt(string datum){
  115.     int p = 256;
  116.     int n = rand();
  117. int IntString = atoi(datum.c_str());
  118. IntString = IntString*pow(p,n);
  119.  
  120.  
  121.  
  122. }
Advertisement
Add Comment
Please, Sign In to add comment