00001
00002
00003
00004
00005 #ifndef OC_INC_H
00006 #define OC_INC_H
00007
00008 #include <cstdlib>
00009 #include <string>
00010
00011 using namespace std;
00012
00013
00014 class ocEnc : public string
00015 {
00016
00017 int lmt;
00018 int mySecret;
00019
00020 public:
00021
00022 ocEnc():string(),lmt(8),mySecret(129038){;}
00023 ocEnc( const char * in ) : string (in),lmt(8),mySecret(129038){;}
00024 ocEnc( const string & in ) : string (in),lmt(8),mySecret(129038){;}
00025
00026
00027 ocEnc & encode( int seed )
00028 {
00029 srand(seed+mySecret);
00030 for( size_type i=0; i< length(); ++i )
00031 {
00032 operator[](i) = operator[](i) - (rand()%lmt);
00033 }
00034 return * this;
00035 }
00036
00037 ocEnc & decode( int seed )
00038 {
00039 srand(seed+mySecret);
00040 for( size_type i=0; i< length(); ++i )
00041 {
00042 operator[](i) = operator[](i) + (rand()%lmt);
00043 }
00044 return * this;
00045 }
00046
00047 ocEnc & shake( int sec, int lmt=8 )
00048 {
00049 this->mySecret=sec;
00050 this->lmt=lmt;
00051 return *this;
00052 }
00053
00054 };
00055
00056 #endif
00057
00058 #ifdef IN_T2_TESTHARNESS
00059 string ary[3]= {
00060 "host=localhost;uid=GOOFYadmin;pwd=12gOOF;db=mig",
00061 "host=localhost;uid=plutoadmin;pwd=34pLUTO;db=boeing",
00062 "host=localhost;uid=dumbouser;pwd=mydeal99;db=airbus"
00063 };
00064
00065 ocEnc encoder = "A-Z,0-9,!@#$%^&*()_+|\\=-`,a-z /?'\";:.>,<my brother 123 is a BRAT 4567890! Zoo Breath is his name.";
00066
00067 cout << "Fresh : " << encoder << endl;
00068 encoder.encode(22);
00069 cout << "Encoded: " << encoder << endl;
00070 encoder.decode(22);
00071 cout << "Decoded: " << encoder << endl;
00072
00073 for( int x=0;x<3;x++ )
00074 {
00075 cout << endl << "========" << endl << endl;
00076 encoder = ary[x];
00077 cout << "Fresh : " << encoder << endl;
00078 encoder.encode(232);
00079 cout << "Encoded : " << encoder << endl;
00080 encoder.decode(232);
00081 cout << "Decoded : " << encoder << endl;
00082
00083 }
00084 #ifdef OC_STRING_H
00085 ocString brash = "davidmc@w3sys.com";
00086 int val = brash.makeHash();
00087 cout << endl << "HASH = " << val << endl;
00088
00089 for( int x=0;x<3;x++ )
00090 {
00091 cout << endl << "HASH KEYED========" << endl << endl;
00092 encoder = ary[x];
00093 encoder.shake( val, 22 );
00094 cout << "Fresh : " << encoder << endl;
00095 encoder.encode(232);
00096 cout << "Encoded : " << encoder << endl;
00097 encoder.decode(232);
00098 cout << "Decoded : " << encoder << endl;
00099
00100 }
00101
00102 #endif
00103
00104 #endif