コード例 #1
0
ファイル: obo.c プロジェクト: bakiez/writeups-2
int main(int argc, char **argv) {
  int i;
  FILE *password_file;
  int digits[16] = {0};
  char password[64];
  char new_password[64];
  char confirm_password[64];

  generate_hex_table();

  password_file = fopen(password_file_path, "r");
  if (password_file == NULL) {
    perror("fopen");
    return 1;
  }
  read_password(password_file, password, sizeof(password));
  fclose(password_file);

  printf("New password: "******"Invalid character: %c\n", new_password[i]);
      exit(1);
    }
    digits[index] = 1;
  }

  for (i = 0; i <= 16; ++i) {
    if (digits[i] == 0) {
      printf("Password is not complex enough: %d\n", i);
      return 1;
    }
  }

  printf("Confirm old password: "******"Old password is incorrect.\n");
    return 1;
  }

  change_password(new_password);
  printf("Password changed!\n");
  return 0;
}
コード例 #2
0
ファイル: test.c プロジェクト: eliotw/ecwong-18739L
int main(int argc, char **argv) {
    int i;
    int digits[16] = {0};
    char password[64] = "oldpassword";
    char new_password[64] = "abcdefABCDEF0123456789";

    generate_hex_table();

    for (i = 0; i <= strlen(new_password); ++i) {
        int index = hex_table[(unsigned char) new_password[i]];
        if (index == -1) {
            printf("Invalid character: %c\n", new_password[i]);
            exit(1);
        }
        digits[index] = 1;
    }

//printf("%s\n", password);

    printf("Hex table\n");
    for(i = 0; i < 256; i++) {
        printf("%d - %d\n", i, hex_table[i]);
    }
}