Envisiontec Ultra 3DP SLA printer/encrypt/decrypt

From NURDspace
Revision as of 03:34, 11 July 2020 by Buzz (talk | contribs) (Created page with "Decompiled C# code from the original binary: <pre> private string Decrypt(string csString) { for (int index = csString.Length - 1; index >= 0; --index) {...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Decompiled C# code from the original binary:

    private string Decrypt(string csString)
    {
      for (int index = csString.Length - 1; index >= 0; --index)
      {
        int iPosB = index;
        int iPosA = this.GetPrimaryIndex(index + 3) % csString.Length;
        this.SwapCharacter(ref csString, iPosA, iPosB);
      }
      return csString;
    }

    private void SwapCharacter(ref string csString, int iPosA, int iPosB)
    {
      char[] charArray = csString.ToCharArray();
      char ch1 = charArray[iPosA];
      char ch2 = charArray[iPosB];
      charArray[iPosA] = ch2;
      charArray[iPosB] = ch1;
      csString = new string(charArray);
    }

    private int GetPrimaryIndex(int iIndex)
    {
      int iInitialIndex = 1;
      for (int index = 1; index < iIndex; ++index)
        iInitialIndex = this.GetNextReturn(iInitialIndex);
      return iInitialIndex;
    }

    private int GetNextReturn(int iInitialIndex)
    {
      int num;
      do
      {
        ++iInitialIndex;
        num = 2;
        while (num < iInitialIndex && iInitialIndex % num != 0)
          ++num;
      }
      while (num != iInitialIndex);
      return iInitialIndex;
    }