• R/O
  • HTTP
  • SSH
  • HTTPS

mhash384: Commit

MHash-384 development repository


Commit MetaInfo

Revision1cc9c895184f6402a9d1f1a53e86f9a67a440482 (tree)
Time2020-01-18 21:08:58
AuthorLoRd_MuldeR <mulder2@gmx....>
CommiterLoRd_MuldeR

Log Message

XOR table generator utility: Improved output formatting + some code clean-up.

Change Summary

Incremental Difference

--- a/etc/gentable_FIN/gentable_FIN.vcxproj
+++ b/etc/gentable_FIN/gentable_FIN.vcxproj
@@ -11,7 +11,7 @@
1111 </ProjectConfiguration>
1212 </ItemGroup>
1313 <ItemGroup>
14- <ClCompile Include="src\gentable_fin.cpp" />
14+ <ClCompile Include="src\gentable_FIN.cpp" />
1515 </ItemGroup>
1616 <PropertyGroup Label="Globals">
1717 <ProjectGuid>{579E7209-F88C-4D5B-A8D6-6FBAF923ABD1}</ProjectGuid>
--- a/etc/gentable_FIN/src/gentable_fin.cpp
+++ b/etc/gentable_FIN/src/gentable_FIN.cpp
@@ -67,6 +67,7 @@ static void create_permutation(uint32_t *const out)
6767 int main()
6868 {
6969 uint32_t permutation[MASH384_SIZE];
70+ printf("MHash GenTableFIN [%s]\n\n", __DATE__);
7071
7172 for(uint32_t i = 997U; i < UINT32_MAX; ++i)
7273 {
@@ -82,15 +83,20 @@ int main()
8283 }
8384 puts("");
8485
86+ printf("\n-----\n\n");
87+
88+ puts("{");
8589 for(size_t i = 0U; i < MASH384_SIZE; ++i)
8690 {
87- printf(((i % 16) > 0U) ? ", 0x%02X" : "0x%02X", permutation[i]);
91+ printf(((i % 16) > 0U) ? ", 0x%02X" : "\t0x%02X", permutation[i]);
8892 if((i % 16U) == 15U)
8993 {
90- puts(",");
94+ puts((i < MASH384_SIZE - 1U) ? "," : "");
9195 }
9296 }
97+ puts("}");
9398
94- puts("\nCompleted.\n");
99+ printf("\nCOMPLETED.\n\n");
100+ getchar();
95101 return EXIT_SUCCESS;
96102 }
--- a/etc/gentable_MIX/gentable_MIX.vcxproj
+++ b/etc/gentable_MIX/gentable_MIX.vcxproj
@@ -11,7 +11,7 @@
1111 </ProjectConfiguration>
1212 </ItemGroup>
1313 <ItemGroup>
14- <ClCompile Include="src\gentable_mix.cpp" />
14+ <ClCompile Include="src\gentable_MIX.cpp" />
1515 </ItemGroup>
1616 <PropertyGroup Label="Globals">
1717 <ProjectGuid>{579E7209-F88C-4D5B-A8D6-6FBAF923ABD1}</ProjectGuid>
--- a/etc/gentable_MIX/gentable_MIX.vcxproj.filters
+++ b/etc/gentable_MIX/gentable_MIX.vcxproj.filters
@@ -15,7 +15,7 @@
1515 </Filter>
1616 </ItemGroup>
1717 <ItemGroup>
18- <ClCompile Include="src\gentable_mix.cpp">
18+ <ClCompile Include="src\gentable_MIX.cpp">
1919 <Filter>Source Files</Filter>
2020 </ClCompile>
2121 </ItemGroup>
--- a/etc/gentable_MIX/src/gentable_mix.cpp
+++ b/etc/gentable_MIX/src/gentable_MIX.cpp
@@ -109,6 +109,8 @@ static void print_row(const size_t row)
109109
110110 int main()
111111 {
112+ printf("MHash GenTableMIX [%s]\n\n", __DATE__);
113+
112114 create_permutation(mix_table[0U]);
113115 print_row(0U);
114116
@@ -128,6 +130,7 @@ int main()
128130 print_row(i);
129131 }
130132
131- puts("\nCompleted.\n");
133+ printf("\nCOMPLETED.\n\n");
134+ getchar();
132135 return EXIT_SUCCESS;
133136 }
--- a/etc/gentable_XOR/src/gentable_XOR.cpp
+++ b/etc/gentable_XOR/src/gentable_XOR.cpp
@@ -45,13 +45,11 @@
4545 #define ROW_NUM (UINT8_MAX+2) /*total number of rows*/
4646 #define ROW_LEN (HASH_LEN / CHAR_BIT) /*number of bits per row*/
4747
48-#define __DISTANCE_STR(X) #X
49-#define _DISTANCE_STR(X) __DISTANCE_STR(X)
50-#define DISTANCE_STR _DISTANCE_STR(DISTANCE_MIN)
51-
5248 #define MAGIC_NUMBER 0x3C6058A7C1132CB2ui64
5349 #define THREAD_ID (pthread_getw32threadid_np(pthread_self()))
5450
51+#define R_OK 0x04
52+
5553 //-----------------------------------------------------------------------------
5654 // Globals
5755 //-----------------------------------------------------------------------------
@@ -150,21 +148,19 @@ static inline uint_fast32_t check_distance_buff(const uint_fast32_t distance_max
150148
151149 static void dump_table(FILE *out)
152150 {
153- fputs("uint8_t MHASH_384_TABLE_XOR[UINT8_MAX+2][MHASH_384_LEN] =\n{\n", out);
154151 for (size_t i = 0; i < ROW_NUM; i++)
155152 {
156- fputs("\t{ ", out);
153+ fputs("{ ", out);
157154 for (size_t j = 0; j < ROW_LEN; j++)
158155 {
159- if (j > 0)
156+ if(!(j % 8U))
160157 {
161- fputc(',', out);
158+ fputs((j > 0U) ? ", 0x" : "0x", out);
162159 }
163- fprintf(out, "0x%02X", g_table[i][j]);
160+ fprintf(out, "%02X", g_table[i][j]);
164161 }
165162 fprintf(out, " }%s /*%02X*/\n", (i != (ROW_NUM - 1)) ? "," : " ", (uint32_t)(i % 0x100));
166163 }
167- fputs("};\n", out);
168164 }
169165
170166 //-----------------------------------------------------------------------------
@@ -450,7 +446,7 @@ static void* thread_spin(void *const param)
450446 return NULL;
451447 }
452448 _sleep(delay);
453- if (delay >= 500)
449+ if (delay >= 1000)
454450 {
455451 printf("\b\b\b[%c]", SPINNER[g_spinpos]);
456452 g_spinpos = (g_spinpos + 1) % 4;
@@ -644,7 +640,7 @@ int wmain(int argc, wchar_t *argv[])
644640 SEM_INIT(&stop_flag);
645641 MUTEX_INIT(&stop_mutex);
646642
647- if (_waccess(argv[1], 4) == 0)
643+ if (_waccess(argv[1], R_OK) == 0)
648644 {
649645 printf("Loading existing table data and proceeding...\n");
650646 if (!load_table_data(argv[1], &initial_row_index, &distance_max))
@@ -656,7 +652,7 @@ int wmain(int argc, wchar_t *argv[])
656652 for (size_t i = initial_row_index; i < ROW_NUM; i++)
657653 {
658654 char time_string[64];
659- printf("\aRow %03u of %03u [%c]", (uint32_t)(i+1U), ROW_NUM, SPINNER[g_spinpos]);
655+ printf("\aRow %03u of %03u [%03u] [%c]", (uint32_t)(i+1U), ROW_NUM, distance_max, SPINNER[g_spinpos]);
660656 g_spinpos = (g_spinpos + 1) % 4;
661657
662658 PTHREAD_CREATE(&thread_id[THREAD_COUNT], NULL, thread_spin, &stop_flag);
@@ -693,13 +689,16 @@ int wmain(int argc, wchar_t *argv[])
693689 }
694690
695691 printf("\n-----\n\n");
696-
692+
697693 dump_table(stdout);
698- if (fopen_s(&file_out, "table_XOR." DISTANCE_STR ".txt", "w") == 0)
699- {
700- dump_table(file_out);
701- fclose(file_out);
702- }
694+
695+ //wchar_t output_name[64U];
696+ //_snwprintf(output_name, 64U, L"table_XOR.%u.txt", DISTANCE_MIN);
697+ //if (_wfopen_s(&file_out, output_name, L"w") == 0)
698+ //{
699+ // dump_table(file_out);
700+ // fclose(file_out);
701+ //}
703702
704703 printf("\n-----\n\n");
705704
@@ -722,6 +721,6 @@ int wmain(int argc, wchar_t *argv[])
722721 MUTEX_DESTROY(&stop_mutex);
723722
724723 printf("COMPLETED.\n\n");
725- system("shutdown /s /t 180");
726- return getchar();
724+ getchar();
725+ return EXIT_SUCCESS;
727726 }
Show on old repository browser