Advertisement
thexiv

comb

Apr 3rd, 2019
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.04 KB | None | 0 0
  1. /*
  2.  * Thank you to Dr. Dr. Morton,
  3.  * Whom without the help of his
  4.  * once in his classroom, I
  5.  * would not have reviled math
  6.  * as I now do -thexiv
  7. */
  8.  
  9. #include <bitset>
  10. #include <fstream>
  11. #include <iostream>
  12. #include <string>
  13. #include <iterator>
  14. #include <algorithm>
  15. #include <vector>
  16. #include <math.h>
  17. using namespace std;
  18.  
  19. class S_Rend {
  20.  
  21.     private:
  22.     const bitset<32> beta=0xad;
  23.  
  24.     protected:
  25.     bitset<32> alpha, lambda;
  26.         bitset<32> delta, tango1, tango2;
  27.  
  28.     vector<unsigned long> cred;
  29.     vector<unsigned long> btrace;
  30.     vector<unsigned long> ltr;
  31.  
  32.     public:
  33.     unsigned long long integral;
  34.     long size;
  35.  
  36.         S_Rend() { delta=0x00; lambda=0x00; alpha=0x00; delta=0x00; };
  37.     ~S_Rend() { };
  38.     long s_render(ifstream&,ofstream&);
  39.     long render(ifstream&,ofstream&);
  40.     long s_nop(long t, long set);
  41.     long dbl_nop(long t);
  42.     long convBit(bitset<32>, bitset<32>, int);
  43.     long recrDelta(long, long);
  44. } n;
  45.  
  46. /*+**- Project::Sailwinds -**+*/
  47.  
  48. long S_Rend::recrDelta(long i, long bn) {
  49.     printf(" **** %u %u", bn, btrace.size());
  50.     if (btrace.size() == cred.size())
  51.         return 1;
  52.  
  53.     for (long long j=256;j>0;j--) {
  54.         printf(" ** ", bn, i);
  55.         alpha = static_cast<unsigned long>(cred[bn-i-1]);
  56.         tango1 = static_cast<long>(j-1);
  57.         tango2 = lambda;
  58.         tango2 ^= alpha;
  59.         tango2 ^= tango1 ^= alpha;
  60.         tango2 ^= tango1;
  61.         tango1 ^= tango2;
  62.         alpha ^= tango2 ^= tango1;
  63.         tango2 ^= alpha;
  64.         tango2 ^= tango1;
  65.         tango1 ^= tango2;
  66.        
  67.         if ((tango2 ^ alpha ^ tango1) == lambda) {
  68.             btrace.push_back(i);
  69.             lambda = tango2;
  70.             i++;
  71.             printf(". %u %u %u %u", cred.size(), j, i, bn);
  72.             return recrDelta(i, bn);
  73.         }
  74.         else {
  75.             printf(" **** %u %u", bn, i);
  76.             tango2 = lambda;
  77.             alpha = static_cast<unsigned long>(cred[bn-i-1]);
  78.         }
  79.     }
  80. }
  81.  
  82.  
  83. long S_Rend::s_nop(long t,long set) {
  84.     if (set) {
  85.         integral=0;
  86.         t= (beta.to_ulong());
  87.     }
  88.     integral+=7;
  89.     return integral;
  90.     if (abs(round((t*1.618)+t-(integral+0.618))-1) <= 4294967296)
  91.         return (abs(round((t*1.618)+integral)-1));
  92.     else
  93.         return (abs(round(sqrt(t))+(round(sqrt(t))*round(sqrt(integral))+1)));
  94. }
  95.  
  96. long S_Rend::dbl_nop(long t) {
  97.  
  98.     bitset<32> tango1 = static_cast<long>(t);
  99.     bitset<8> rev;
  100.     for (int i=0;i<8;i++) {
  101.         rev[i] = tango1[i];
  102.     }
  103.     return rev.to_ulong();
  104. }
  105.  
  106. long S_Rend::render(ifstream& in, ofstream& out) {
  107.  
  108.     long bn;
  109.     long t;
  110.     if (!(in.is_open()))
  111.     { return -1; }
  112.     else {
  113.     t= (beta.to_ulong());
  114.     size=0;
  115.  
  116.     for_each (std::istreambuf_iterator<char>(in), \
  117.         std::istreambuf_iterator<char>(), \
  118.         [&] (char x) {
  119.         t=s_nop(t,0);
  120.         cred.push_back(t);
  121.         alpha = static_cast<long>(cred[size]);
  122.         delta = static_cast<long>(x);
  123.         lambda ^= (alpha ^ delta);
  124.         size++;
  125.     });
  126.  
  127.         printf("*");
  128.     }
  129.     if (out.is_open())
  130.     { out << lambda << endl;
  131.         out << size << endl;
  132.             out << cred[size-1] << endl; }
  133.  
  134.     else { return -1; }
  135.     in.close();
  136.     out.close();
  137.     return 0;
  138. }
  139.  
  140. long S_Rend::convBit(bitset<32> A, bitset<32> B, int transform=0) {
  141.  
  142.     long rtrn=0;
  143.     for (int i=0;i<=31;i++) {
  144.         int binA = A[i];
  145.         int binB = B[i];
  146.         bitset<1> BAC;
  147.  
  148.         bitset<1> Ab = static_cast<long>(binA);
  149.         bitset<1> Ba = static_cast<long>(binB);
  150.         bitset<1> def = 1;
  151.  
  152.         switch (transform) {
  153.             case 2:
  154.                 BAC = Ab | Ba | def;
  155.             break;
  156.             case 1:
  157.                 BAC = Ab & Ba & def;
  158.             break;
  159.             default:
  160.                 BAC = Ab ^ Ba ^ def;
  161.         }
  162.         rtrn += BAC.to_ulong() * (2^i);
  163.     }
  164.     return rtrn;
  165. }
  166.  
  167. long S_Rend::s_render(ifstream& in, ofstream& out) {
  168.  
  169.     long i, n;
  170.     long t;
  171.     long chk;
  172.     in >> lambda;
  173.     in >> size;
  174.     in >> chk;
  175.     t= (beta.to_ulong());
  176.     long bn=0;
  177.  
  178.     cout << lambda.to_string();
  179.  
  180.     while (size>bn) {
  181.         t=s_nop(t,0);
  182.         cred.push_back(t);
  183.         bn++;      
  184.     }
  185.  
  186.     if (cred[bn-1]==chk)
  187.         cout << "\nValidity Pass... Success!" << endl;
  188.     else {
  189.         printf("\nValidity Pass...Fail! %u != %u",cred[cred.size()-1],chk);
  190.         return 1;
  191.     }
  192.  
  193.     cout << "\nWriting to Buffer..." << endl;
  194.  
  195.     recrDelta(0,bn);
  196.  
  197.     cout << "\nDecompression check...";
  198.     tango1=0x00;
  199.     for (int j=0;j<=bn-1;j++) {
  200.         alpha = static_cast<long>(cred[bn-j-1]);
  201.         delta = static_cast<long>(btrace[j]);
  202.         tango1 ^= alpha ^ delta;
  203.     }
  204.     if (tango1 == lambda) {
  205.         cout << tango1 << " " << lambda;
  206.         return 1;
  207.     }
  208.     cout << "SUCCESS!\n";
  209.     cout << "One more second..\n";
  210.     i=0;
  211.     while (i<=size-1) {
  212.         i++;
  213.         out << (const char)(short int&)(btrace[i]);
  214.     }
  215.  
  216.     cout << "\nBuffer Written... Exiting..\n";
  217.     in.close();
  218.     out.close();
  219.     printf("*");
  220.     return 0;
  221. }
  222.  
  223. int main() {
  224.  
  225.     string outfile = "";
  226.     string infile = "";
  227.     string DC = "1";
  228.     printf("Enter <C> or <D> to compress or decompress ");
  229.     cin >> DC;
  230.  
  231.     printf("\nInput File: ");
  232.     cin >> infile;
  233.     ifstream in;
  234.     in.open(infile.c_str(), std::ios::in | std::ios::binary);
  235.  
  236.     if (in.fail())
  237.         return -1;
  238.  
  239.     printf("\nOutput File: ");
  240.     cin >> outfile;
  241.     ofstream out;
  242.     out.open(outfile.c_str(), std::ios::out);
  243.  
  244.     if (out.fail())
  245.         return -1;
  246.  
  247.     if ((DC=="c") || (DC=="C"))
  248.             bool f=n.render(in, out);
  249.     if ((DC=="d") || (DC=="D"))
  250.             bool f=n.s_render(in, out);
  251.  
  252.     printf("\nProgram Execution Done.");
  253.  
  254.  
  255.     n.~S_Rend();
  256.     return 0;
  257.  
  258. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement