Skip to content

Instantly share code, notes, and snippets.

@yohanes

yohanes/re-faq1.c Secret

Created Dec 7, 2018
Embed
What would you like to do?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static int is_serial_valid(const char *user, const char *serial)
{
int i, total;
for (i=0; i < strlen(user); i++) {
total += user[i];
}
for (i=0; i < strlen(serial); i++) {
total += serial[i];
}
return (((total + 17)*100057)%1871)==812;
}
int main(int argc, char *argv[])
{
char *user;
char *serial;
if (argc<3) {
printf("Usage: serial3 <user> <serial>\n");
return 0;
}
user = argv[1];
serial = argv[2];
if (is_serial_valid(user, serial)) {
printf("correct serial\n");
} else {
printf("incorrect serial\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment