MCPcopy Create free account
hub / github.com/Endermanch/XPKeygen / IsValidCheckDigit

Function IsValidCheckDigit

pidgen/util.cpp:27–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25
26
27BOOL IsValidCheckDigit(DWORD dw)
28{
29 // validates check digit given 7-digit sequence + check-digit
30
31 int iLastDigit = dw%10;
32 BOOL fIsvalid = TRUE;
33 DWORD dwSum = 0;
34
35
36 switch (dw%10) // last digit
37 {
38 case 0:
39 case 8:
40 case 9:
41 fIsvalid = FALSE;
42 break;
43
44 default:
45 while (dw != 0)
46 {
47 dwSum += dw % 10;
48 dw /= 10;
49 }
50 fIsvalid = (0 == dwSum % 7);
51 }
52 return fIsvalid;
53}
54
55
56DWORD AddCheckDigit(DWORD dw)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected