mirror of https://github.com/tongzx/nt5src
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
437 lines
9.8 KiB
437 lines
9.8 KiB
/*++
|
|
|
|
Copyright (C) 1999-2001 Microsoft Corporation
|
|
|
|
Module Name:
|
|
|
|
Abstract:
|
|
|
|
History:
|
|
|
|
--*/
|
|
|
|
#include <windows.h>
|
|
#include <stdio.h>
|
|
|
|
DWORD g_aData[] =
|
|
{
|
|
787298196, 389638077,
|
|
341926582, 774741813,
|
|
93260522, 163092950,
|
|
1990849060, 347345683,
|
|
877836976, 1572821297,
|
|
648067937, 2085921890,
|
|
185524536, 456812682,
|
|
0, 757935405,
|
|
0, 757935405,
|
|
0, 757935405,
|
|
0, 757935405,
|
|
137293882, 647272253,
|
|
926837903, 691288938,
|
|
2110722223, 753493867,
|
|
1158850856, 231595791,
|
|
891966499, 1864871608,
|
|
369617977, 1136871300,
|
|
1171009120, 869085779,
|
|
1450103344, 1086868440,
|
|
1961959123, 1059058093,
|
|
1935842809, 802291789,
|
|
67991817, 981707677,
|
|
1259917513, 326492489,
|
|
1576246720, 1771986875,
|
|
0, 757935405,
|
|
0, 757935405,
|
|
0, 757935405,
|
|
0, 757935405,
|
|
923580586, 196610576,
|
|
422396857, 1268611680,
|
|
612189215, 1446180055,
|
|
273627650, 1037431929,
|
|
1582243822, 530725520,
|
|
802440210, 1390869936,
|
|
1406698670, 882125910,
|
|
1438991232, 560627627,
|
|
519127596, 452431388,
|
|
247297193, 1875650637,
|
|
1095739709, 1333936659,
|
|
488415888, 58615958,
|
|
2113012991, 1738890481,
|
|
1232434023, 576968899,
|
|
408785170, 2004132969,
|
|
1072488881, 1949997283,
|
|
686278613, 103342821,
|
|
1802391228, 1692614641,
|
|
1467267833, 20439818,
|
|
1881687054, 139215331,
|
|
883980780, 1810507476,
|
|
328677840, 457133755,
|
|
142591755, 1983286802,
|
|
1996404059, 1271126329,
|
|
1134573462, 762500247,
|
|
1814903789, 840278466,
|
|
1546035302, 748041854,
|
|
1627769996, 1594286475,
|
|
485134963, 1356626587,
|
|
985018630, 725840743,
|
|
894740359, 1781303086,
|
|
191459340, 113223348,
|
|
1637410797, 99004090,
|
|
1314737521, 1672532217,
|
|
1668536725, 1304979453,
|
|
1000359187, 88572926,
|
|
940387879, 86954543,
|
|
581549221, 1279191550,
|
|
582252523, 1728435494,
|
|
1684935272, 658131775,
|
|
120729547, 480600746,
|
|
1434799119, 1826855997,
|
|
132314003, 890416705,
|
|
1550628941, 1593392703,
|
|
212468432, 1977475751,
|
|
145875476, 1283143786,
|
|
339648658, 1258446305,
|
|
1259855840, 1196087906,
|
|
74939557, 525823171,
|
|
282953689, 879773678,
|
|
702241042, 1008129545,
|
|
529353019, 143169584,
|
|
0, 543978849,
|
|
0, 1701604417,
|
|
371789987, 422923611,
|
|
1151970391, 221238405,
|
|
1680390471, 894991504,
|
|
1173777616, 157967432,
|
|
1766201693, 1082091029,
|
|
961250332, 418310210,
|
|
2064488210, 1090270119,
|
|
2001088245, 1778413437,
|
|
791205667, 120892331,
|
|
425237262, 1210731199,
|
|
905501056, 1963224902,
|
|
1495907077, 1762779656,
|
|
1793196122, 900671011,
|
|
565554614, 877067351,
|
|
1684925417, 1390111021,
|
|
1324408981, 1523119716,
|
|
1985677317, 1014717431,
|
|
2058211074, 325132225,
|
|
1158869461, 1242277359,
|
|
940757120, 1456714425,
|
|
1912286107, 1599660744,
|
|
1030658283, 1328068605,
|
|
1672026279, 818606002,
|
|
1811916152, 731129312,
|
|
62148729, 371093903,
|
|
300023322, 1713323730,
|
|
1016690981, 453549345,
|
|
1591860349, 929856991,
|
|
1154873655, 1234446286,
|
|
1969529918, 889192916,
|
|
506902349, 1583269362,
|
|
596405421, 29222317,
|
|
1957020972, 428224461,
|
|
705503535, 1900946280,
|
|
1636949272, 753322603,
|
|
1574175218, 74107011,
|
|
620920752, 2000334733,
|
|
286975576, 1272973499,
|
|
832394219, 1049983536,
|
|
719744492, 863138508,
|
|
152013962, 961843672,
|
|
92216887, 220011621,
|
|
2005324671, 676471875,
|
|
801005260, 2107228857,
|
|
1417629424, 1535412939,
|
|
927485975, 971812307,
|
|
440891913, 2031435089,
|
|
2075684028, 1235594918,
|
|
15075279, 255504492,
|
|
1292850514, 1653838496,
|
|
1575207405, 771884304,
|
|
762297916, 113481758,
|
|
1344439445, 1543107246,
|
|
852400584, 1804221292,
|
|
1525438309, 110908311,
|
|
86765426, 771128997,
|
|
697445823, 961217353,
|
|
21213263, 1351154252,
|
|
10599418, 1651444261,
|
|
35441527, 1052114448,
|
|
1590203695, 1004220318,
|
|
526682473, 905611632,
|
|
1769355382, 1506382359,
|
|
44165446, 222203003,
|
|
1796395753, 236997150,
|
|
1183262379, 1958681932,
|
|
874728503, 1225185820,
|
|
570241278, 732193933,
|
|
858685714, 2074455587,
|
|
1560512242, 570149966,
|
|
951907138, 1616617795,
|
|
1487056392, 1358244054,
|
|
970286561, 92310071,
|
|
756933636, 1110268445,
|
|
1440979143, 1265100897,
|
|
2084942205, 818510862,
|
|
1320638918, 823264617,
|
|
1971233622, 1847199921,
|
|
95431188, 242470127,
|
|
856458457, 897727972,
|
|
329752498, 468812383,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
534716163, 1761870124,
|
|
1020475911, 15843303,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
1067808548, 208610277,
|
|
211579674, 1653240566,
|
|
239108456, 885154717,
|
|
21370838, 1331889325,
|
|
981841190, 31603421,
|
|
776487910, 155411510,
|
|
2071731226, 122456632,
|
|
124476971, 416326125,
|
|
763251302, 178690314,
|
|
1119537894, 126896069,
|
|
806112306, 1933102105,
|
|
364993844, 1805041121,
|
|
1424534966, 727711589,
|
|
2077763860, 274369686,
|
|
2093089868, 1733803912,
|
|
84954222, 1079628647,
|
|
264022324, 2037751576,
|
|
1024375655, 434843389,
|
|
1902071860, 2111102903,
|
|
695270825, 1907355848,
|
|
1911415748, 1337430371,
|
|
971966920, 1236686408,
|
|
2033536277, 945241688,
|
|
1505165919, 920928449,
|
|
1140463463, 867695560,
|
|
425854658, 1224833536,
|
|
1898028372, 1356457614,
|
|
1790370482, 816827286,
|
|
451463270, 1522918624,
|
|
1281670814, 931443332,
|
|
405066436, 2107792490,
|
|
261570442, 204422508,
|
|
1182010752, 1359667668,
|
|
520647196, 199392831,
|
|
1232260743, 1016215239,
|
|
1066977689, 1846685821,
|
|
1393055485, 1149327626,
|
|
728869925, 1227807534,
|
|
1223562861, 1215769115,
|
|
1234782934, 1500675318,
|
|
1670384851, 1546713131,
|
|
680528633, 517371164,
|
|
1190806955, 761856969,
|
|
2145532613, 1742670338,
|
|
1002949577, 295468350,
|
|
538754217, 2099052296,
|
|
1487886738, 1318580638,
|
|
1540413980, 1248769325,
|
|
203789634, 144460909,
|
|
1948818884, 1383042119,
|
|
1106605766, 249692350,
|
|
1654887685, 799220325,
|
|
266335729, 1064242885,
|
|
935948902, 1729316369,
|
|
1904596453, 602576498,
|
|
1393926903, 1868790805,
|
|
999121367, 1482517664,
|
|
1106424117, 1619863692,
|
|
475802887, 1065758854,
|
|
1578128863, 1073664523,
|
|
1902406644, 1490177493,
|
|
189884687, 370196266,
|
|
2067425084, 1295173952,
|
|
719320527, 1966542348,
|
|
1402266308, 627647129,
|
|
321290752, 563241132,
|
|
1055096585, 1304486941,
|
|
923108668, 487059104,
|
|
344621029, 714650744,
|
|
1350621712, 1393479868,
|
|
496766707, 337566155,
|
|
1398161423, 1065556157,
|
|
1637951588, 1664109644,
|
|
1897844973, 39233871,
|
|
738269405, 2096910723,
|
|
92694589, 236509435,
|
|
1190806955, 761856969,
|
|
338757023, 812768206,
|
|
1849559800, 854377249,
|
|
1404336425, 1207126318,
|
|
1662034928, 342925931,
|
|
658926774, 426922867,
|
|
1729186771, 1061508106,
|
|
563502611, 1697133477,
|
|
840094768, 1210950740,
|
|
1835414483, 769859538,
|
|
747821704, 1438378136,
|
|
2126687472, 278562278,
|
|
1238007326, 59100431,
|
|
1897844973, 39233871,
|
|
450014323, 1915307751,
|
|
1426814736, 286322278,
|
|
846462709, 324087749,
|
|
1264181614, 609866356,
|
|
537228654, 1155735254,
|
|
1669911731, 295201152,
|
|
2051750308, 1634959694,
|
|
2037895850, 1121635198,
|
|
1191562139, 871349233,
|
|
384085527, 1485591712,
|
|
593489313, 1334053277,
|
|
1201558042, 1284197474,
|
|
1267301451, 1295178886,
|
|
712333739, 1466813771,
|
|
1382958161, 55608330,
|
|
1404336425, 1207126318,
|
|
1420100579, 1516550283,
|
|
1034307423, 253077413,
|
|
364993844, 1805041121,
|
|
2107257906, 1288714714,
|
|
2127080717, 1122861179,
|
|
496953976, 480397759,
|
|
1539886260, 2049877054,
|
|
1458240017, 1918020923,
|
|
1736195893, 934320622,
|
|
270972983, 295012450,
|
|
1020551866, 2134232563,
|
|
673302697, 1363075082,
|
|
329752498, 468812383,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
1764104557, 547082180,
|
|
497927576, 24480816,
|
|
589828949, 1975205479,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
602187998, 287638516,
|
|
2008233392, 1060225789,
|
|
1192430968, 1339353572,
|
|
1428531475, 1905392579,
|
|
1670384851, 1546713131,
|
|
680528633, 517371164,
|
|
330641664, 1605658617,
|
|
664197573, 1993238793,
|
|
329752498, 468812383,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
337739951, 76463872,
|
|
1786957427, 416636494,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
363957482, 713099117,
|
|
715207258, 1444991911,
|
|
906492934, 201308803,
|
|
549588084, 1261979109,
|
|
1198999088, 295629922,
|
|
1456701468, 2004408543,
|
|
1587159928, 1248983505,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
1067808548, 208610277,
|
|
156509796, 1042008667,
|
|
426198684, 1629282820,
|
|
301389858, 1871183307,
|
|
593620859, 1798829104,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
144227962, 769935106,
|
|
1067808548, 208610277,
|
|
941907548, 507139560,
|
|
1042233049, 945161939,
|
|
807955139, 99055478,
|
|
999121367, 1482517664,
|
|
1308773551, 1409554373,
|
|
1523086598, 413771652,
|
|
52391019, 1186011222,
|
|
563372826, 1525327567,
|
|
2102151822, 1136009315,
|
|
1574765603, 1457921496,
|
|
867496441, 1693047572,
|
|
407929249, 542656253,
|
|
1795844148, 255267812,
|
|
1218529061, 1059803448,
|
|
39529162, 1398686543,
|
|
490430000, 1686718086,
|
|
489233830, 1863308304
|
|
};
|
|
|
|
#define NUM_DATA (sizeof(g_aData)/sizeof(DWORD))
|
|
#define LARGE_PRIME 2147483659
|
|
|
|
DWORD HashKey(char* szKey)
|
|
{
|
|
DWORD n = 1;
|
|
while(*szKey)
|
|
{
|
|
n = n * (2*(DWORD)*szKey + 1);
|
|
szKey++;
|
|
}
|
|
return n % LARGE_PRIME;
|
|
}
|
|
|
|
LPSTR GetText(LPSTR szKey)
|
|
{
|
|
LPSTR szResult = new char[NUM_DATA*2+4];
|
|
DWORD* pdwResult = (DWORD*)szResult;
|
|
|
|
DWORD dwKey = HashKey(szKey);
|
|
for(int i = 0; i < NUM_DATA; i+=2)
|
|
{
|
|
__int64 i64A = g_aData[i];
|
|
__int64 i64B = g_aData[i+1];
|
|
__int64 i64Res = (i64A*dwKey + i64B) % LARGE_PRIME;
|
|
*pdwResult = (DWORD)i64Res;
|
|
pdwResult++;
|
|
}
|
|
*pdwResult = 0;
|
|
|
|
return szResult;
|
|
}
|
|
|
|
BOOL CheckText(char* szText)
|
|
{
|
|
while(*szText)
|
|
{
|
|
if (*szText < 8 || *szText > 127)
|
|
return FALSE;
|
|
szText++;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
void main()
|
|
{
|
|
printf("Key: ");
|
|
char szKey[100];
|
|
scanf("%s", szKey);
|
|
LPSTR szResult = GetText(szKey);
|
|
if(!CheckText(szResult))
|
|
printf("INVALID!\n");
|
|
else
|
|
printf("%s\n", szResult);
|
|
}
|