Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Thank you to Dr. Dr. Morton,
- * Whom without the help of his
- * once in his classroom, I
- * would not have reviled math
- * as I now do -thexiv
- */
- #include <bitset>
- #include <fstream>
- #include <iostream>
- #include <string>
- #include <iterator>
- #include <algorithm>
- #include <vector>
- #include <math.h>
- using namespace std;
- class S_Rend {
- private:
- const bitset<32> beta=0xad;
- protected:
- bitset<32> alpha, lambda;
- bitset<32> delta, tango1, tango2;
- vector<unsigned long> cred;
- vector<unsigned long> btrace;
- vector<unsigned long> ltr;
- public:
- unsigned long long integral;
- long size;
- S_Rend() { delta=0x00; lambda=0x00; alpha=0x00; delta=0x00; };
- ~S_Rend() { };
- long s_render(ifstream&,ofstream&);
- long render(ifstream&,ofstream&);
- long s_nop(long t, long set);
- long dbl_nop(long t);
- long convBit(bitset<32>, bitset<32>, int);
- long recrDelta(long, long);
- } n;
- /*+**- Project::Sailwinds -**+*/
- long S_Rend::recrDelta(long i, long bn) {
- printf(" **** %u %u", bn, btrace.size());
- if (btrace.size() == cred.size())
- return 1;
- for (long long j=256;j>0;j--) {
- printf(" ** ", bn, i);
- alpha = static_cast<unsigned long>(cred[bn-i-1]);
- tango1 = static_cast<long>(j-1);
- tango2 = lambda;
- tango2 ^= alpha;
- tango2 ^= tango1 ^= alpha;
- tango2 ^= tango1;
- tango1 ^= tango2;
- alpha ^= tango2 ^= tango1;
- tango2 ^= alpha;
- tango2 ^= tango1;
- tango1 ^= tango2;
- if ((tango2 ^ alpha ^ tango1) == lambda) {
- btrace.push_back(i);
- lambda = tango2;
- i++;
- printf(". %u %u %u %u", cred.size(), j, i, bn);
- return recrDelta(i, bn);
- }
- else {
- printf(" **** %u %u", bn, i);
- tango2 = lambda;
- alpha = static_cast<unsigned long>(cred[bn-i-1]);
- }
- }
- }
- long S_Rend::s_nop(long t,long set) {
- if (set) {
- integral=0;
- t= (beta.to_ulong());
- }
- integral+=7;
- return integral;
- if (abs(round((t*1.618)+t-(integral+0.618))-1) <= 4294967296)
- return (abs(round((t*1.618)+integral)-1));
- else
- return (abs(round(sqrt(t))+(round(sqrt(t))*round(sqrt(integral))+1)));
- }
- long S_Rend::dbl_nop(long t) {
- bitset<32> tango1 = static_cast<long>(t);
- bitset<8> rev;
- for (int i=0;i<8;i++) {
- rev[i] = tango1[i];
- }
- return rev.to_ulong();
- }
- long S_Rend::render(ifstream& in, ofstream& out) {
- long bn;
- long t;
- if (!(in.is_open()))
- { return -1; }
- else {
- t= (beta.to_ulong());
- size=0;
- for_each (std::istreambuf_iterator<char>(in), \
- std::istreambuf_iterator<char>(), \
- [&] (char x) {
- t=s_nop(t,0);
- cred.push_back(t);
- alpha = static_cast<long>(cred[size]);
- delta = static_cast<long>(x);
- lambda ^= (alpha ^ delta);
- size++;
- });
- printf("*");
- }
- if (out.is_open())
- { out << lambda << endl;
- out << size << endl;
- out << cred[size-1] << endl; }
- else { return -1; }
- in.close();
- out.close();
- return 0;
- }
- long S_Rend::convBit(bitset<32> A, bitset<32> B, int transform=0) {
- long rtrn=0;
- for (int i=0;i<=31;i++) {
- int binA = A[i];
- int binB = B[i];
- bitset<1> BAC;
- bitset<1> Ab = static_cast<long>(binA);
- bitset<1> Ba = static_cast<long>(binB);
- bitset<1> def = 1;
- switch (transform) {
- case 2:
- BAC = Ab | Ba | def;
- break;
- case 1:
- BAC = Ab & Ba & def;
- break;
- default:
- BAC = Ab ^ Ba ^ def;
- }
- rtrn += BAC.to_ulong() * (2^i);
- }
- return rtrn;
- }
- long S_Rend::s_render(ifstream& in, ofstream& out) {
- long i, n;
- long t;
- long chk;
- in >> lambda;
- in >> size;
- in >> chk;
- t= (beta.to_ulong());
- long bn=0;
- cout << lambda.to_string();
- while (size>bn) {
- t=s_nop(t,0);
- cred.push_back(t);
- bn++;
- }
- if (cred[bn-1]==chk)
- cout << "\nValidity Pass... Success!" << endl;
- else {
- printf("\nValidity Pass...Fail! %u != %u",cred[cred.size()-1],chk);
- return 1;
- }
- cout << "\nWriting to Buffer..." << endl;
- recrDelta(0,bn);
- cout << "\nDecompression check...";
- tango1=0x00;
- for (int j=0;j<=bn-1;j++) {
- alpha = static_cast<long>(cred[bn-j-1]);
- delta = static_cast<long>(btrace[j]);
- tango1 ^= alpha ^ delta;
- }
- if (tango1 == lambda) {
- cout << tango1 << " " << lambda;
- return 1;
- }
- cout << "SUCCESS!\n";
- cout << "One more second..\n";
- i=0;
- while (i<=size-1) {
- i++;
- out << (const char)(short int&)(btrace[i]);
- }
- cout << "\nBuffer Written... Exiting..\n";
- in.close();
- out.close();
- printf("*");
- return 0;
- }
- int main() {
- string outfile = "";
- string infile = "";
- string DC = "1";
- printf("Enter <C> or <D> to compress or decompress ");
- cin >> DC;
- printf("\nInput File: ");
- cin >> infile;
- ifstream in;
- in.open(infile.c_str(), std::ios::in | std::ios::binary);
- if (in.fail())
- return -1;
- printf("\nOutput File: ");
- cin >> outfile;
- ofstream out;
- out.open(outfile.c_str(), std::ios::out);
- if (out.fail())
- return -1;
- if ((DC=="c") || (DC=="C"))
- bool f=n.render(in, out);
- if ((DC=="d") || (DC=="D"))
- bool f=n.s_render(in, out);
- printf("\nProgram Execution Done.");
- n.~S_Rend();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement