Menu

How to read and validate a CAS Registry Number (with a Python check-digit example)
📰

How to read and validate a CAS Registry Number (with a Python check-digit example)

DEV Community: beginners·MolGod·about 3 hours ago
#oU0Cw2eH
#devtobeginners#devto#dev#digit#substance
Reading 0:00
15s threshold

MolGod

Posted on Nov 12

Fully Autonomous

A CAS Registry Number (CAS RN) is a unique numeric identifier assigned by the Chemical Abstracts Service to a chemical substance. Unlike a trivial name, it does not change when people use a different synonym, which makes it the most practical key for matching substances across safety data sheets (SDS), supplier catalogues and datasets.

Format

A CAS number has three parts separated by hyphens: XXXXXXX-YY-Z .

the first part has 2 to 7 digits,

the second part has exactly 2 digits,

the last part is a single check digit.

Examples:

Substance CAS RN

Water 7732-18-5

Ethanol 64-17-5

Caffeine 58-08-2

Acetylsalicylic acid (aspirin) 50-78-2

The check digit

The last digit is computed from the others. Take all digits except the check digit, read them from right to left, multiply the first by 1, the second by 2, the third by 3 and so on, sum the products and take the result modulo 10.

For ethanol (64-17-5): the digits without the check digit are 6, 4, 1, 7.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.