s
Section 5.6 The Mighty Mod Function
435
There is the slight possibility that user A and user B could pick different
passwords that hash to the same value, or even that A and B pick the same password. As far as ordinary usage is concerned, this doesn’t matter; both A and B
will be authenticated as legitimate users. However, if A steals the password file
(no longer securely protected), A could notice that user B’s password hashes to
the same value as A’s, and if indeed the passwords are the same, A could log
in as B and do damage to B’s files. Most password encryption schemes append
some sort of timestamp to a password when the password is first created, and
(password + timestamp) is encrypted. If A and B choose the same password,
their timestamps (and hashed values) will differ. The timestamp is stored in
the password file along with the user ID and when the user enters his or her
password, the timestamp is appended and the result hashed and compared to
the table entry.
Miscellaneous applications
Identification Codes
Sometimes codes are used for identification purposes, not the “secret code”
purposes we discussed earlier.
example 55
An international standard book Number, or ISBN, is a numeric identification
code associated with a published book. The 10-digit ISBN standard was adopted
in 1970, but it was replaced by a 13-digit ISBN standard in 2007. Books published
since 2007 generally carry both a 10-digit code and a 13-digit code.
The ISBN-10 is written as four blocks of digits separated by hyphens or blanks.
Reading left to right, the first block of digits is a group identifier for a country, area,
or language area participating in the ISBN system, the second block of digits identifies the publisher within that group, and the third block is the number assigned by
the publisher to this particular work. The final block consists of a single digit from
0–9 or a single X to represent 10. If the first nine digits of the ISBN-10 are
a 1 a 2 a 3 a 4 a 5 a 6 a 7 a 8 a 9
then the tenth digit, or check digit, C, is computed by the formula
C = c ∙
9
i=1
i(a i ) d mod 11
—that is, sum up the product of each digit times its position in the list and to the
result apply the modulo 11 function.
For example, in the ISBN-10 0-394-80001-X, the 0 indicates the English
language group, the 394 identifies the publisher as Random House, the 80001
identifies the title The Cat in the Hat by Dr. Seuss, and the check digit X (10) is
computed from
[1 # 0 + 2 # 3 + 3 # 9 + 4 # 4 + 5 # 8 + 6 # 0 + 7 # 0 + 8 # 0 + 9 # 1] mod 11 =
98 mod 11 = 10
The purpose of the check digit is to detect certain types of errors in the ISBN code,
such as a mistyped digit or a transposition of two digits.
Section 5.6 The Mighty Mod Function
435
There is the slight possibility that user A and user B could pick different
passwords that hash to the same value, or even that A and B pick the same password. As far as ordinary usage is concerned, this doesn’t matter; both A and B
will be authenticated as legitimate users. However, if A steals the password file
(no longer securely protected), A could notice that user B’s password hashes to
the same value as A’s, and if indeed the passwords are the same, A could log
in as B and do damage to B’s files. Most password encryption schemes append
some sort of timestamp to a password when the password is first created, and
(password + timestamp) is encrypted. If A and B choose the same password,
their timestamps (and hashed values) will differ. The timestamp is stored in
the password file along with the user ID and when the user enters his or her
password, the timestamp is appended and the result hashed and compared to
the table entry.
Miscellaneous applications
Identification Codes
Sometimes codes are used for identification purposes, not the “secret code”
purposes we discussed earlier.
example 55
An international standard book Number, or ISBN, is a numeric identification
code associated with a published book. The 10-digit ISBN standard was adopted
in 1970, but it was replaced by a 13-digit ISBN standard in 2007. Books published
since 2007 generally carry both a 10-digit code and a 13-digit code.
The ISBN-10 is written as four blocks of digits separated by hyphens or blanks.
Reading left to right, the first block of digits is a group identifier for a country, area,
or language area participating in the ISBN system, the second block of digits identifies the publisher within that group, and the third block is the number assigned by
the publisher to this particular work. The final block consists of a single digit from
0–9 or a single X to represent 10. If the first nine digits of the ISBN-10 are
a 1 a 2 a 3 a 4 a 5 a 6 a 7 a 8 a 9
then the tenth digit, or check digit, C, is computed by the formula
C = c ∙
9
i=1
i(a i ) d mod 11
—that is, sum up the product of each digit times its position in the list and to the
result apply the modulo 11 function.
For example, in the ISBN-10 0-394-80001-X, the 0 indicates the English
language group, the 394 identifies the publisher as Random House, the 80001
identifies the title The Cat in the Hat by Dr. Seuss, and the check digit X (10) is
computed from
[1 # 0 + 2 # 3 + 3 # 9 + 4 # 4 + 5 # 8 + 6 # 0 + 7 # 0 + 8 # 0 + 9 # 1] mod 11 =
98 mod 11 = 10
The purpose of the check digit is to detect certain types of errors in the ISBN code,
such as a mistyped digit or a transposition of two digits.
