Advertisement
ImoogiWild

Untitled

Jun 4th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.54 KB | None | 0 0
  1. // ResMan.Classes.KeyCodeLibrary
  2. using System;
  3. using System.Text;
  4.  
  5. internal static class KeyCodeLibrary
  6. {
  7. private const long S11 = 7L;
  8.  
  9. private const long S12 = 12L;
  10.  
  11. private const long S13 = 17L;
  12.  
  13. private const long S14 = 22L;
  14.  
  15. private const long S21 = 5L;
  16.  
  17. private const long S22 = 9L;
  18.  
  19. private const long S23 = 14L;
  20.  
  21. private const long S24 = 20L;
  22.  
  23. private const long S31 = 4L;
  24.  
  25. private const long S32 = 11L;
  26.  
  27. private const long S33 = 16L;
  28.  
  29. private const long S34 = 23L;
  30.  
  31. private const long S41 = 6L;
  32.  
  33. private const long S42 = 10L;
  34.  
  35. private const long S43 = 15L;
  36.  
  37. private const long S44 = 21L;
  38.  
  39. public const string MyProductName = "ResManV131";
  40.  
  41. public const string B32Map = "0123456789ABCDEFGHJKLMNPRSTVWXYZ";
  42.  
  43. private const long OFFSET_4 = 4294967296L;
  44.  
  45. private const long MAXINT_4 = 2147483647L;
  46.  
  47. public static long ByteCounter;
  48.  
  49. public static long[] State;
  50.  
  51. public static byte[] ByteBuffer;
  52.  
  53. public static string GenKeyString(string UserName, string ProdName, long F_Code)
  54. {
  55. string text = null;
  56. string text2 = null;
  57. char[] array = null;
  58. long num = 0L;
  59. byte b = 0;
  60. byte b2 = 0;
  61. byte b3 = 0;
  62. byte b4 = 0;
  63. text = UserName.ToLower() + ProdName.ToLower();
  64. text2 = DigestStrToHexStr(text);
  65. array = HexStrToBinStr(text2);
  66. num = (F_Code & 0xFFFF);
  67. b = (byte)(num & 0xFF);
  68. b2 = (byte)((num & 0xFF00) / 256 & 0xFF);
  69. char c = array[array.Length - 1];
  70. char c2 = array[array.Length - 2];
  71. b3 = (byte)c;
  72. b4 = (byte)c2;
  73. b3 = (byte)(b3 ^ b);
  74. b4 = (byte)(b4 ^ b2);
  75. char c3 = (char)b3;
  76. char c4 = (char)b4;
  77. string text3 = new string(array);
  78. text3 = text3.Substring(0, array.Length - 2);
  79. text3 = text3 + c4 + c3;
  80. text3 = text3.Substring(2, text3.Length - 2);
  81. string text4 = DigestStrToHexStr(text3);
  82. string str = text4.Substring(0, 2);
  83. string str2 = text4.Substring(text4.Length - 2, 2);
  84. string str3 = BinStrToHexStr(text3);
  85. return str + str2 + str3;
  86. }
  87.  
  88. public static string Base32Enc(string StrIn)
  89. {
  90. byte b = 0;
  91. long num = 0L;
  92. byte b2 = 0;
  93. long num2 = 0L;
  94. long num3 = 0L;
  95. string text = null;
  96. string text2 = null;
  97. string text3 = null;
  98. int num4 = 0;
  99. int num5 = 0;
  100. text2 = "";
  101. text = StrIn;
  102. num2 = StrIn.Length * 8;
  103. num4 = (int)(num2 / 5);
  104. if (num2 % 5 != 0)
  105. {
  106. num4++;
  107. }
  108. num5 = StrIn.Length;
  109. num3 = 0L;
  110. b = 31;
  111. for (num = 0L; num < num4; num++)
  112. {
  113. b2 = (byte)text[text.Length - 1];
  114. b2 = (byte)((b2 & b) + 1);
  115. text3 = "0123456789ABCDEFGHJKLMNPRSTVWXYZ".Substring(b2 - 1, 1);
  116. text = MyShiftToRight(text, 5L);
  117. text2 = text3 + text2;
  118. }
  119. return text2;
  120. }
  121.  
  122. public static string BinStrToHexStr(string StrIn)
  123. {
  124. string text = "";
  125. foreach (char value in StrIn)
  126. {
  127. string text2 = Convert.ToString(value, 16);
  128. if (text2.Length == 1)
  129. {
  130. text2 = "0" + text2;
  131. }
  132. text += text2;
  133. }
  134. return text;
  135. }
  136.  
  137. public static bool ValidateKeyCode(string KeyCode, string UserName, string ProjName)
  138. {
  139. string text = "";
  140. string text2 = "";
  141. string text3 = "";
  142. string text4 = "";
  143. bool flag = false;
  144. if (KeyCode.Length == 32)
  145. {
  146. string text5 = new string(HexStrToBinStr(KeyCode));
  147. text = text5.Substring(text5.Length - 14, 14);
  148. string text6 = DigestStrToHexStr(text);
  149. text4 = text6.Substring(0, 2) + text6.Substring(text6.Length - 2, 2);
  150. text3 = KeyCode.Substring(0, 4);
  151. if (text3.ToUpper() == text4.ToUpper())
  152. {
  153. flag = true;
  154. }
  155. if (flag)
  156. {
  157. string sourceString = UserName.ToLower() + ProjName.ToLower();
  158. text2 = DigestStrToHexStr(sourceString);
  159. text = KeyCode.Substring(4, 24);
  160. text2 = text2.Substring(4, 24);
  161. }
  162. if (text.ToUpper() == text2.ToUpper())
  163. {
  164. flag = true;
  165. }
  166. }
  167. else
  168. {
  169. flag = false;
  170. }
  171. return flag;
  172. }
  173.  
  174. public static string RemoveDashes(string StrIn)
  175. {
  176. return StrIn.Replace("-", "");
  177. }
  178.  
  179. public static string Base32Dec(string StrIn)
  180. {
  181. int num = 0;
  182. byte b = 0;
  183. string text = null;
  184. string text2 = null;
  185. byte b2 = 0;
  186. long num2 = 0L;
  187. long num3 = 0L;
  188. try
  189. {
  190. num3 = StrIn.Length * 5;
  191. num2 = Convert.ToInt64(num3 / 8);
  192. for (num = 0; num < num2; num++)
  193. {
  194. text += '\0';
  195. }
  196. foreach (char value in StrIn)
  197. {
  198. b = Convert.ToByte("0123456789ABCDEFGHJKLMNPRSTVWXYZ".IndexOf(value));
  199. text = MyShift(text, 5L);
  200. char c = text[text.Length - 1];
  201. text = text.Substring(0, text.Length - 1);
  202. b2 = (byte)c;
  203. b2 = (byte)(b2 | b);
  204. c = (char)b2;
  205. text += c;
  206. byte b3 = (byte)text[text.Length - 2];
  207. }
  208. }
  209. catch (Exception)
  210. {
  211. return "";
  212. }
  213. return text;
  214. }
  215.  
  216. public static string MyShift(string StrIn, long Bits)
  217. {
  218. string text = "";
  219. byte b = 0;
  220. long num = 0L;
  221. string text2 = null;
  222. num = Convert.ToInt64(Bits / 8);
  223. b = Convert.ToByte(Bits % 8);
  224. int length = StrIn.Length;
  225. text2 = StrIn;
  226. if (length * 8 > Bits)
  227. {
  228. if (num > 0)
  229. {
  230. text2 = text2.Substring(length, (int)(length - num));
  231. for (int i = 0; i < num; i++)
  232. {
  233. text2 += '\0';
  234. }
  235. }
  236. byte b2 = 0;
  237. string text3 = "";
  238. for (int i = length - 1; i >= 0; i--)
  239. {
  240. byte b3 = (byte)text2[i];
  241. byte b4 = (byte)((int)b3 / (int)(byte)Math.Pow(2.0, (double)(8 - b)));
  242. byte b5 = (byte)((int)b3 % (int)(byte)Math.Pow(2.0, (double)(8 - b)));
  243. b3 = (byte)((double)(int)b5 * Math.Pow(2.0, (double)(int)b));
  244. b3 = Convert.ToByte(b3 | b2);
  245. text3 += (char)b3;
  246. b2 = b4;
  247. }
  248. text = "";
  249. for (int i = length - 1; i >= 0; i--)
  250. {
  251. text += text3[i];
  252. }
  253. }
  254. else
  255. {
  256. for (int i = 0; i < length; i++)
  257. {
  258. text += '\0';
  259. }
  260. }
  261. return text;
  262. }
  263.  
  264. public static string ShiftStrLeft(string StrIn, long Bits)
  265. {
  266. int num = 0;
  267. string text = null;
  268. string text2 = null;
  269. byte b = 0;
  270. byte b2 = 0;
  271. byte b3 = 0;
  272. byte b4 = 0;
  273. long num2 = 0L;
  274. byte b5 = 0;
  275. byte b6 = 0;
  276. byte b7 = 0;
  277. byte b8 = 0;
  278. num2 = Convert.ToInt64(Bits / 8);
  279. b4 = Convert.ToByte(Bits % 8);
  280. b2 = Convert.ToByte(255.0 - (Math.Pow(2.0, (double)(8 - b4)) - 1.0));
  281. b3 = (byte)(~b2);
  282. b8 = Convert.ToByte(Math.Pow(2.0, (double)(int)b4) - 1.0);
  283. num = 0;
  284. int length = StrIn.Length;
  285. int num3 = length * 8;
  286. text = StrIn;
  287. if (num3 > Bits)
  288. {
  289. if (num2 > 0)
  290. {
  291. text = text.Substring(length, (int)(length - num2));
  292. for (num = 0; num < num2; num++)
  293. {
  294. text += '\0';
  295. }
  296. text2 = text;
  297. }
  298. if (b4 > 0)
  299. {
  300. for (num = 0; num < text.Length; num++)
  301. {
  302. byte[] bytes = Encoding.ASCII.GetBytes(text.Substring(num, 1));
  303. b = bytes[0];
  304. b5 = Convert.ToByte(b & b2 & 0xFF);
  305. b6 = Convert.ToByte(b & b3 & 0xFF);
  306. b5 = (byte)((double)(int)b5 / Math.Pow(2.0, (double)(8 - b4)));
  307. b6 = (byte)((double)(int)b6 * Math.Pow(2.0, (double)(int)b4));
  308. if (num == 0)
  309. {
  310. b7 = b6;
  311. text2 = "";
  312. }
  313. else
  314. {
  315. b7 = (byte)(b7 | b5);
  316. text2 += (char)b7;
  317. b7 = b6;
  318. }
  319. }
  320. b7 = (byte)(b7 | (b5 & ~b8));
  321. text2 += (char)b7;
  322. }
  323. }
  324. else
  325. {
  326. for (num = 0; num < length; num++)
  327. {
  328. text2 += '\0';
  329. }
  330. }
  331. return text2;
  332. }
  333.  
  334. public static string MyShiftToRight(string StrIn, long Bits)
  335. {
  336. string text = "";
  337. byte b = 0;
  338. long num = 0L;
  339. string text2 = null;
  340. num = Convert.ToInt64(Bits / 8);
  341. b = Convert.ToByte(Bits % 8);
  342. int length = StrIn.Length;
  343. text2 = StrIn;
  344. if (length * 8 > Bits)
  345. {
  346. if (num > 0)
  347. {
  348. text2 = text2.Substring(length, (int)(length - num));
  349. for (int i = 0; i < num; i++)
  350. {
  351. text2 += '\0';
  352. }
  353. }
  354. byte b2 = 0;
  355. string text3 = "";
  356. for (int i = 0; i < length; i++)
  357. {
  358. byte b3 = (byte)text2[i];
  359. byte b4 = (byte)((int)b3 / (int)(byte)Math.Pow(2.0, (double)(int)b));
  360. byte b5 = (byte)((int)b3 % (int)(byte)Math.Pow(2.0, (double)(int)b));
  361. b3 = b4;
  362. b3 = Convert.ToByte(b3 | b2 * (byte)Math.Pow(2.0, (double)(8 - b)));
  363. text3 += (char)b3;
  364. b2 = b5;
  365. }
  366. text = "";
  367. for (int i = 0; i < length; i++)
  368. {
  369. text += text3[i];
  370. }
  371. }
  372. else
  373. {
  374. for (int i = 0; i < length; i++)
  375. {
  376. text += '\0';
  377. }
  378. }
  379. return text;
  380. }
  381.  
  382. public static char[] HexStrToBinStr(string StrIn)
  383. {
  384. char[] array = new char[StrIn.Length / 2];
  385. for (int i = 0; i < StrIn.Length - 1; i += 2)
  386. {
  387. string value = StrIn.Substring(i, 2);
  388. byte b = Convert.ToByte(value, 16);
  389. char c = (char)b;
  390. array[i / 2] = (char)b;
  391. }
  392. return array;
  393. }
  394.  
  395. private static string DigestStrToHexStr(string SourceString)
  396. {
  397. MD5Init();
  398. byte[] inputBuffer = StringToArray(SourceString);
  399. MD5Update(SourceString.Length, inputBuffer);
  400. MD5Final();
  401. return GetValues();
  402. }
  403.  
  404. private static byte[] StringToArray(string InString)
  405. {
  406. byte[] array = new byte[InString.Length + 1];
  407. for (int i = 0; i <= InString.Length; i++)
  408. {
  409. if (i == InString.Length)
  410. {
  411. array[i] = 0;
  412. }
  413. else
  414. {
  415. array[i] = (byte)InString[i];
  416. }
  417. }
  418. return array;
  419. }
  420.  
  421. private static string GetValues()
  422. {
  423. return LongToString(State[0]) + LongToString(State[1]) + LongToString(State[2]) + LongToString(State[3]);
  424. }
  425.  
  426. private static string LongToString(long Num)
  427. {
  428. string text = "";
  429. byte[] array = new byte[1];
  430. byte[] array2 = new byte[1];
  431. byte[] array3 = new byte[1];
  432. byte[] array4 = new byte[1];
  433. array[0] = (byte)(Num & 0xFF);
  434. array2[0] = (byte)((Num & 0xFF00) / 256);
  435. array3[0] = (byte)((Num & 0xFF0000) / 65536);
  436. text = BitConverter.ToString(array).Replace("-", "");
  437. text += BitConverter.ToString(array2).Replace("-", "");
  438. text += BitConverter.ToString(array3).Replace("-", "");
  439. if (Num < 0)
  440. {
  441. array4[0] = (byte)((Num & 0x7F000000) / 16777216 | 0x80);
  442. }
  443. else
  444. {
  445. array4[0] = (byte)((Num & 4278190080u) / 16777216);
  446. }
  447. return text + BitConverter.ToString(array4).Replace("-", "");
  448. }
  449.  
  450. private static void MD5Final()
  451. {
  452. byte[] array = new byte[72]
  453. {
  454. 128,
  455. 0,
  456. 0,
  457. 0,
  458. 0,
  459. 0,
  460. 0,
  461. 0,
  462. 0,
  463. 0,
  464. 0,
  465. 0,
  466. 0,
  467. 0,
  468. 0,
  469. 0,
  470. 0,
  471. 0,
  472. 0,
  473. 0,
  474. 0,
  475. 0,
  476. 0,
  477. 0,
  478. 0,
  479. 0,
  480. 0,
  481. 0,
  482. 0,
  483. 0,
  484. 0,
  485. 0,
  486. 0,
  487. 0,
  488. 0,
  489. 0,
  490. 0,
  491. 0,
  492. 0,
  493. 0,
  494. 0,
  495. 0,
  496. 0,
  497. 0,
  498. 0,
  499. 0,
  500. 0,
  501. 0,
  502. 0,
  503. 0,
  504. 0,
  505. 0,
  506. 0,
  507. 0,
  508. 0,
  509. 0,
  510. 0,
  511. 0,
  512. 0,
  513. 0,
  514. 0,
  515. 0,
  516. 0,
  517. 0,
  518. 0,
  519. 0,
  520. 0,
  521. 0,
  522. 0,
  523. 0,
  524. 0,
  525. 0
  526. };
  527. long value = ByteCounter * 8;
  528. long num = ByteCounter % 64;
  529. if (num <= 56)
  530. {
  531. MD5Update(56 - num, array);
  532. }
  533. else
  534. {
  535. MD5Update(120 - ByteCounter, array);
  536. }
  537. array[0] = (byte)(UnsignedToLong(value) & 0xFF);
  538. array[1] = (byte)((int)(UnsignedToLong(value) / 256) & 0xFF);
  539. array[2] = (byte)((int)(UnsignedToLong(value) / 65536) & 0xFF);
  540. array[3] = (byte)((int)(UnsignedToLong(value) / 16777216) & 0xFF);
  541. array[4] = 0;
  542. array[5] = 0;
  543. array[6] = 0;
  544. array[7] = 0;
  545. MD5Update(8L, array);
  546. }
  547.  
  548. private static void MD5Init()
  549. {
  550. ByteCounter = 0L;
  551. State[0] = UnsignedToLong(1732584193L);
  552. State[1] = UnsignedToLong(4023233417L);
  553. State[2] = UnsignedToLong(2562383102L);
  554. State[3] = UnsignedToLong(271733878L);
  555. }
  556.  
  557. private static long UnsignedToLong(long value)
  558. {
  559. if (value < 0 || value >= 4294967296L)
  560. {
  561. return 6L;
  562. }
  563. if (value <= 2147483647)
  564. {
  565. return value;
  566. }
  567. return value - 4294967296L;
  568. }
  569.  
  570. private static long LongToUnsigned(long value)
  571. {
  572. if (value < 0)
  573. {
  574. return value + 4294967296L;
  575. }
  576. return value;
  577. }
  578.  
  579. private static void MD5Update(long InputLen, byte[] InputBuffer)
  580. {
  581. long num = ByteCounter % 64;
  582. long num2 = 64 - num;
  583. ByteCounter += InputLen;
  584. long num5;
  585. if (InputLen >= num2)
  586. {
  587. long num3;
  588. for (num3 = 0L; num3 < num2; num3++)
  589. {
  590. ByteBuffer[num + num3] = InputBuffer[num3];
  591. }
  592. MD5Transform(ByteBuffer);
  593. long num4 = InputLen % 64;
  594. for (num5 = num2; num5 <= InputLen - num3 - num4; num5 += 64)
  595. {
  596. for (long num6 = 0L; num6 < 64; num6++)
  597. {
  598. ByteBuffer[num6] = InputBuffer[num5 + num6];
  599. }
  600. MD5Transform(ByteBuffer);
  601. }
  602. num = 0L;
  603. }
  604. else
  605. {
  606. num5 = 0L;
  607. }
  608. for (long num7 = 0L; num7 < InputLen - num5; num7++)
  609. {
  610. ByteBuffer[num + num7] = InputBuffer[num5 + num7];
  611. }
  612. }
  613.  
  614. private static void MD5Transform(byte[] Buffer)
  615. {
  616. long num = State[0];
  617. long num2 = State[1];
  618. long num3 = State[2];
  619. long num4 = State[3];
  620. long[] array = Decode(64, Buffer);
  621. FF(ref num, num2, num3, num4, array[0], 7L, -680876936L);
  622. FF(ref num4, num, num2, num3, array[1], 12L, -389564586L);
  623. FF(ref num3, num4, num, num2, array[2], 17L, 606105819L);
  624. FF(ref num2, num3, num4, num, array[3], 22L, -1044525330L);
  625. FF(ref num, num2, num3, num4, array[4], 7L, -176418897L);
  626. FF(ref num4, num, num2, num3, array[5], 12L, 1200080426L);
  627. FF(ref num3, num4, num, num2, array[6], 17L, -1473231341L);
  628. FF(ref num2, num3, num4, num, array[7], 22L, -45705983L);
  629. FF(ref num, num2, num3, num4, array[8], 7L, 1770035416L);
  630. FF(ref num4, num, num2, num3, array[9], 12L, -1958414417L);
  631. FF(ref num3, num4, num, num2, array[10], 17L, -42063L);
  632. FF(ref num2, num3, num4, num, array[11], 22L, -1990404162L);
  633. FF(ref num, num2, num3, num4, array[12], 7L, 1804603682L);
  634. FF(ref num4, num, num2, num3, array[13], 12L, -40341101L);
  635. FF(ref num3, num4, num, num2, array[14], 17L, -1502002290L);
  636. FF(ref num2, num3, num4, num, array[15], 22L, 1236535329L);
  637. GG(ref num, num2, num3, num4, array[1], 5L, -165796510L);
  638. GG(ref num4, num, num2, num3, array[6], 9L, -1069501632L);
  639. GG(ref num3, num4, num, num2, array[11], 14L, 643717713L);
  640. GG(ref num2, num3, num4, num, array[0], 20L, -373897302L);
  641. GG(ref num, num2, num3, num4, array[5], 5L, -701558691L);
  642. GG(ref num4, num, num2, num3, array[10], 9L, 38016083L);
  643. GG(ref num3, num4, num, num2, array[15], 14L, -660478335L);
  644. GG(ref num2, num3, num4, num, array[4], 20L, -405537848L);
  645. GG(ref num, num2, num3, num4, array[9], 5L, 568446438L);
  646. GG(ref num4, num, num2, num3, array[14], 9L, -1019803690L);
  647. GG(ref num3, num4, num, num2, array[3], 14L, -187363961L);
  648. GG(ref num2, num3, num4, num, array[8], 20L, 1163531501L);
  649. GG(ref num, num2, num3, num4, array[13], 5L, -1444681467L);
  650. GG(ref num4, num, num2, num3, array[2], 9L, -51403784L);
  651. GG(ref num3, num4, num, num2, array[7], 14L, 1735328473L);
  652. GG(ref num2, num3, num4, num, array[12], 20L, -1926607734L);
  653. HH(ref num, num2, num3, num4, array[5], 4L, -378558L);
  654. HH(ref num4, num, num2, num3, array[8], 11L, -2022574463L);
  655. HH(ref num3, num4, num, num2, array[11], 16L, 1839030562L);
  656. HH(ref num2, num3, num4, num, array[14], 23L, -35309556L);
  657. HH(ref num, num2, num3, num4, array[1], 4L, -1530992060L);
  658. HH(ref num4, num, num2, num3, array[4], 11L, 1272893353L);
  659. HH(ref num3, num4, num, num2, array[7], 16L, -155497632L);
  660. HH(ref num2, num3, num4, num, array[10], 23L, -1094730640L);
  661. HH(ref num, num2, num3, num4, array[13], 4L, 681279174L);
  662. HH(ref num4, num, num2, num3, array[0], 11L, -358537222L);
  663. HH(ref num3, num4, num, num2, array[3], 16L, -722521979L);
  664. HH(ref num2, num3, num4, num, array[6], 23L, 76029189L);
  665. HH(ref num, num2, num3, num4, array[9], 4L, -640364487L);
  666. HH(ref num4, num, num2, num3, array[12], 11L, -421815835L);
  667. HH(ref num3, num4, num, num2, array[15], 16L, 530742520L);
  668. HH(ref num2, num3, num4, num, array[2], 23L, -995338651L);
  669. II(ref num, num2, num3, num4, array[0], 6L, -198630844L);
  670. II(ref num4, num, num2, num3, array[7], 10L, 1126891415L);
  671. II(ref num3, num4, num, num2, array[14], 15L, -1416354905L);
  672. II(ref num2, num3, num4, num, array[5], 21L, -57434055L);
  673. II(ref num, num2, num3, num4, array[12], 6L, 1700485571L);
  674. II(ref num4, num, num2, num3, array[3], 10L, -1894986606L);
  675. II(ref num3, num4, num, num2, array[10], 15L, -1051523L);
  676. II(ref num2, num3, num4, num, array[1], 21L, -2054922799L);
  677. II(ref num, num2, num3, num4, array[8], 6L, 1873313359L);
  678. II(ref num4, num, num2, num3, array[15], 10L, -30611744L);
  679. II(ref num3, num4, num, num2, array[6], 15L, -1560198380L);
  680. II(ref num2, num3, num4, num, array[13], 21L, 1309151649L);
  681. II(ref num, num2, num3, num4, array[4], 6L, -145523070L);
  682. II(ref num4, num, num2, num3, array[11], 10L, -1120210379L);
  683. II(ref num3, num4, num, num2, array[2], 15L, 718787259L);
  684. II(ref num2, num3, num4, num, array[9], 21L, -343485551L);
  685. State[0] = LongOverflowAdd(State[0], num);
  686. State[1] = LongOverflowAdd(State[1], num2);
  687. State[2] = LongOverflowAdd(State[2], num3);
  688. State[3] = LongOverflowAdd(State[3], num4);
  689. }
  690.  
  691. private static void FF(ref long A, long B, long C, long D, long X, long S, long ac)
  692. {
  693. A = LongOverflowAdd4(A, (B & C) | (~B & D), X, ac);
  694. A = LongLeftRotate(A, S);
  695. A = LongOverflowAdd(A, B);
  696. }
  697.  
  698. private static void GG(ref long A, long B, long C, long D, long X, long S, long ac)
  699. {
  700. A = LongOverflowAdd4(A, (B & D) | (C & ~D), X, ac);
  701. A = LongLeftRotate(A, S);
  702. A = LongOverflowAdd(A, B);
  703. }
  704.  
  705. private static void HH(ref long A, long B, long C, long D, long X, long S, long ac)
  706. {
  707. A = LongOverflowAdd4(A, B ^ C ^ D, X, ac);
  708. A = LongLeftRotate(A, S);
  709. A = LongOverflowAdd(A, B);
  710. }
  711.  
  712. private static void II(ref long A, long B, long C, long D, long X, long S, long ac)
  713. {
  714. A = LongOverflowAdd4(A, C ^ (B | ~D), X, ac);
  715. A = LongLeftRotate(A, S);
  716. A = LongOverflowAdd(A, B);
  717. }
  718.  
  719. private static long LongLeftRotate(long value, long Bits)
  720. {
  721. Bits %= 32;
  722. if (Bits == 0)
  723. {
  724. return value;
  725. }
  726. long num = 0L;
  727. for (long num2 = 1L; num2 <= Bits; num2++)
  728. {
  729. long num3 = value & -1073741824;
  730. value = (value & 0x3FFFFFFF) * 2;
  731. num = value;
  732. int num4 = (num3 < 0) ? 1 : 0;
  733. if (num3 < 0 && num3 != -1073741824)
  734. {
  735. value += num4;
  736. }
  737. if (num3 == 1073741824)
  738. {
  739. value += -2147483648;
  740. }
  741. if (num3 == -1073741824)
  742. {
  743. value = value + -2147483648 + 1;
  744. }
  745. }
  746. return value;
  747. }
  748.  
  749. private static long LongOverflowAdd(long Val1, long Val2)
  750. {
  751. long num = (Val1 & 0xFFFF) + (Val2 & 0xFFFF);
  752. long num2 = num / 65536;
  753. long num3 = (Val1 & 4294901760u) / 65536 + (Val2 & 4294901760u) / 65536 + num2 & 0xFFFF;
  754. return UnsignedToLong(num3 * 65536 + (num & 0xFFFF));
  755. }
  756.  
  757. private static long LongOverflowAdd4(long Val1, long Val2, long val3, long val4)
  758. {
  759. long num = (Val1 & 0xFFFF) + (Val2 & 0xFFFF) + (val3 & 0xFFFF) + (val4 & 0xFFFF);
  760. long num2 = num / 65536;
  761. long num3 = (Val1 & 4294901760u) / 65536 + (Val2 & 4294901760u) / 65536 + (val3 & 4294901760u) / 65536 + (val4 & 4294901760u) / 65536 + num2 & 0xFFFF;
  762. return UnsignedToLong(num3 * 65536 + (num & 0xFFFF));
  763. }
  764.  
  765. private static long[] Decode(int Length, byte[] InputBuffer)
  766. {
  767. long[] array = new long[Length / 4];
  768. int num = 0;
  769. for (int i = 0; i < Length; i += 4)
  770. {
  771. double num2 = (double)(InputBuffer[i] + InputBuffer[i + 1] * 256 + InputBuffer[i + 2] * 65536 + InputBuffer[i + 3] * 16777216);
  772. array[num] = (long)num2;
  773. num++;
  774. }
  775. return array;
  776. }
  777.  
  778. public static string FormatKeyCode(string StrIn, int GrpLen)
  779. {
  780. int num = 0;
  781. int num2 = 0;
  782. string text = null;
  783. string text2 = null;
  784. int num3 = 0;
  785. int num4 = 0;
  786. num = StrIn.Length;
  787. int num5 = num / GrpLen;
  788. num4 = num % GrpLen;
  789. for (num2 = 0; num2 < num5; num2++)
  790. {
  791. num3 = num2 * GrpLen;
  792. text2 = StrIn.Substring(num3, GrpLen);
  793. text = ((num2 <= 0) ? (text + text2) : (text + "-" + text2));
  794. }
  795. if (num4 > 0)
  796. {
  797. text = text + "-" + StrIn.Substring(StrIn.Length - num4, num4);
  798. }
  799. return text;
  800. }
  801. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement