Guest User

Untitled

a guest
Feb 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.06 KB | None | 0 0
  1. //.h file code:
  2.  
  3. using namespace System;
  4.  
  5. public:
  6. String ^Encrypt(String ^CodeKey, String ^DataIn);
  7.  
  8.     String ^Decrypt(String ^CodeKey, String ^DataIn);
  9. ustub;
  10. /u;
  11.  
  12. Public Function ^(ByVal CodeKey As String, ByVal DataIn As String) As String;
  13.   Int64 lonDataPtr = 0;
  14.   String ^strDataOut = nullptr;
  15.   int intXOrValue1 = 0;
  16.   int intXOrValue2 = 0;
  17.  
  18.   for (lonDataPtr = 1; lonDataPtr <= (DataIn->Length / 2.0); lonDataPtr++)
  19.   {
  20.     intXOrValue1 = Microsoft::VisualBasic::Conversion::Val("&H" + (DataIn->Substring((2 * lonDataPtr) - 2, 2)));
  21.     intXOrValue2 = Convert::ToInt32(CodeKey[((lonDataPtr % CodeKey->Length) + 1) - 1]);
  22.  
  23.     strDataOut = strDataOut + (safe_cast<Char>(intXOrValue1 ^ intXOrValue2))->ToString();
  24.   }
  25.   xEncryption = strDataOut;
  26.     }
  27.  
  28. //.cpp file code:
  29.  
  30. using namespace System;
  31.  
  32. String ^<missing_class_definition>::Encrypt(String ^CodeKey, String ^DataIn)
  33. {
  34.   Int64 lonDataPtr = 0;
  35.   String ^strDataOut = nullptr;
  36.   int temp = 0;
  37.   String ^tempstring = nullptr;
  38.   int intXOrValue1 = 0;
  39.   int intXOrValue2 = 0;
  40.   for (lonDataPtr = 1; lonDataPtr <= DataIn->Length; lonDataPtr++)
  41.   {
  42.     intXOrValue1 = Convert::ToInt32(DataIn[lonDataPtr - 1]);
  43.     intXOrValue2 = Convert::ToInt32(CodeKey[((lonDataPtr % CodeKey->Length) + 1) - 1]);
  44.  
  45.     temp = (intXOrValue1 ^ intXOrValue2);
  46.     tempstring = Convert::ToString(temp, 16)->ToUpper();
  47.     if (tempstring->Length == 1)
  48.     {
  49.         tempstring = "0" + tempstring;
  50.     }
  51.     strDataOut = strDataOut + tempstring;
  52.   }
  53.   return strDataOut;
  54.     }
  55.  
  56. String ^<missing_class_definition>::Decrypt(String ^CodeKey, String ^DataIn)
  57. {
  58.   Int64 lonDataPtr = 0;
  59.   String ^strDataOut = nullptr;
  60.   int intXOrValue1 = 0;
  61.   int intXOrValue2 = 0;
  62.  
  63.   for (lonDataPtr = 1; lonDataPtr <= (DataIn->Length / 2.0); lonDataPtr++)
  64.   {
  65. intXOrValue1 = Microsoft::VisualBasic::Conversion::Val("&H" + (DataIn->Substring((2 * lonDataPtr) - 2, 2)));
  66. intXOrValue2 = Convert::ToInt32(CodeKey[((lonDataPtr % CodeKey->Length) + 1) - 1]);
  67.  
  68. strDataOut = strDataOut + (safe_cast<Char>(intXOrValue1 ^ intXOrValue2))->ToString();
  69.   }
  70.   return strDataOut;
  71. }
Add Comment
Please, Sign In to add comment