Advertisement
EddyCZ

passwordDeriver

Nov 10th, 2019
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 KB | None | 0 0
  1. private static string DeriveKey(string enteredKey)
  2.   {
  3.    const int BLOCK_SIZE = 32;
  4.    int R = enteredKey.Length << 8 % 64;
  5.    int S = enteredKey.Length << 8 % 64;
  6.    int T = enteredKey.Length << 16 % 36;
  7.    int[][] STATE = new int[enteredKey.Length][];
  8.    byte[] result = new byte[BLOCK_SIZE];
  9.    ulong temp = BLOCK_SIZE / 2;
  10.  
  11.    for (int i = 0; i < BLOCK_SIZE; i++)
  12.    {
  13.     for (int j = 0; j < enteredKey.Length; j++)
  14.     {
  15.      for (int k = 0; k < BLOCK_SIZE; k++)
  16.      {
  17.       R += enteredKey[j];
  18.       for (int l = 0; l < 10; l++)
  19.       {
  20.        S -= k << l;
  21.       }
  22.       S += enteredKey[j];
  23.       T += enteredKey[j];
  24.       for (int l = 0; l < 100; l++)
  25.       {
  26.        T -= j << j;
  27.       }
  28.       temp += (ulong)(T % S % R);
  29.       temp += 16;
  30.      }
  31.      int counter = BLOCK_SIZE;
  32.      while (counter > 0)
  33.      {
  34.       STATE[j] = new int[3] { R, S, T };
  35.       R += S;
  36.       S += T;
  37.       T += R;
  38.       counter--;
  39.      }
  40.     }
  41.     temp = 0;
  42.     for (int m = 0; m < BLOCK_SIZE; m++)
  43.     {
  44.      for (int si = 0; si < 3; si++)
  45.      {
  46.       temp += (ulong)(STATE[m][si] << BLOCK_SIZE);
  47.      }
  48.      result[i] ^= (byte)(temp | temp >> 8 | temp >> 16 | temp >> 24);
  49.     }
  50.    }
  51.    string finalResult = Convert.ToBase64String(result);
  52.    return finalResult;
  53.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement