time is 64b better to accept the same size input timestamps

This commit is contained in:
iceman1001 2023-02-21 04:40:48 +01:00
parent 9b331b37ae
commit 49a475899a
3 changed files with 9 additions and 4 deletions

View file

@ -111,7 +111,8 @@ int main(int argc, char *argv[]) {
uint8_t tag_challenge[16] = {0x00};
uint8_t lock_challenge[32] = {0x00};
uint64_t timestamp = atoi(argv[1]);
uint64_t timestamp = 0;
sscanf(argv[1], "%lu", &timestamp);
if (argc != 4) {
printf("\nusage: %s <unix timestamp> <16 byte tag challenge> <32 byte lock challenge>\n\n", argv[0]);
@ -124,8 +125,10 @@ int main(int argc, char *argv[]) {
if (hexstr_to_byte_array(argv[3], lock_challenge, sizeof(lock_challenge)))
return 3;
// current time
uint64_t start_time = time(NULL);
// from a time before up until current time.
for (; timestamp < start_time; timestamp++) {
make_key(timestamp, key);

View file

@ -233,7 +233,8 @@ int main(int argc, char *argv[]) {
if (argc != 4) return usage(argv[0]);
uint64_t start_time = atoi(argv[1]);
uint64_t start_time = 0;
sscanf(argv[1], "%lu", &start_time);
uint8_t tag_challenge[16] = {0x00};
if (hexstr_to_byte_array(argv[2], tag_challenge, sizeof(tag_challenge)))

View file

@ -172,7 +172,7 @@ static void print_time(uint64_t at) {
char res[32];
strftime(res, sizeof(res), "%Y-%m-%d %H:%M:%S", &lt);
printf("%u ( '%s' )\n", (unsigned)t, res);
printf("%"PRIu64" ( '%s' )\n", t, res);
}
static void *brute_thread(void *arguments) {
@ -378,7 +378,8 @@ int main(int argc, char *argv[]) {
return 1;
}
uint64_t start_time = atoi(argv[3]);
uint64_t start_time = 0;
sscanf(argv[3], "%lu", &start_time);
printf("Crypto algo............ " _GREEN_("%s") "\n", algostr);
printf("LCR Random generator... " _GREEN_("%s") "\n", generators[g_idx].Name);