Skip to content

Instantly share code, notes, and snippets.

@yohanes
Created December 7, 2018 04:17
Show Gist options
  • Save yohanes/4680db8ee6f27a9d3ce5ea5d35b967cc to your computer and use it in GitHub Desktop.
Save yohanes/4680db8ee6f27a9d3ce5ea5d35b967cc to your computer and use it in GitHub Desktop.
#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