Skip to main content

ciencia-id

Validation of the Ciência ID check digit (ISO/IEC 7064, MOD 17,16). Zero dependencies, Python 3.9+.

Install

pip install ciencia-id

Usage

from ciencia_id import is_valid, parse, compute_check_digit, normalize, format, SOURCES

is_valid("EA11-91C2-39D1")                 # True
compute_check_digit("EA1191C239D")         # "1"  (11 hex digits in, check digit out; None if malformed)
normalize(" https://www.ciencia-id.pt/ea11-91c2-39d1\n")  # "EA1191C239D1"
format("ea1191c239d1")                     # "EA11-91C2-39D1"  (the check digit is not verified)
format("ea1191c239d1", True)               # "ciencia-id.pt/EA11-91C2-39D1"
parse("EA11-91C2-39D1")
# ParseResult(
#   status="CIENCIA_ID", reason=None, warnings=(),
#   internal_validation="EA",
#   source=Source(code="1", known=True, name="Ciência ID", domain="ciencia-id.pt"),
#   unique_id="191C239D", unique_id_decimal=421274525,
#   check_digit="1", indicated_domain=None)

Input is trimmed of ASCII whitespace, upper-cased (ASCII only), stripped of an optional http(s)://, www. and ciencia-id.pt/ or estudante-id.pt/ prefix, and stripped of -. Anything else (en dashes, no-break spaces, inner spaces, ligatures) is rejected as FORMAT.

Non-string input (bytes, numbers, lists, ...) is treated as invalid (FORMAT), like None.

Prefer import ciencia_id and call ciencia_id.format(...): from ciencia_id import format shadows the builtin format.

Statuses

status Meaning
CIENCIA_ID Well-formed, check digit correct, known source.
UNKNOWN_SOURCE Well-formed, check digit correct, but the source code (3rd digit) is not known to this library. It may be a typo that the check digit happened to miss, or the library may be out of date.
INVALID See reason: FORMAT (not 12 hex digits after normalisation) or CHECK_DIGIT (check digit mismatch). All other fields are None.

CIENCIA_ID does not guarantee that the ID was ever issued, nor does it verify the internal validation digits; it only says the check digit is consistent.

DOMAIN_MISMATCH

warnings contains "DOMAIN_MISMATCH" when the input carried a domain prefix that differs from the domain of the ID's source (for example estudante-id.pt/EA11-91C2-39D1). The warning does not change status or is_valid. For an unknown source, any domain prefix counts as a mismatch.

Historical note

The check-digit mechanism was designed for two identifiers: Ciência ID (in use, source 1) and Estudante-ID, which was never implemented, has no source code assigned and will not get one. The library is named after Ciência ID, but the algorithm also supports Estudante-ID, for historical reasons: the estudante-id.pt/ prefix is accepted on input and yields the DOMAIN_MISMATCH warning.

Known limitation

The check digit detects every single-character substitution, but not every adjacent transposition: at each position exactly one of the 120 possible pairs of distinct hex digits can be swapped undetected (about 1 in 120). In particular, swapping the last data digit and the check digit goes undetected when they are 0 and 1, so an ID ending in 01 and the same ID ending in 10 both validate (e.g. 1C11-C5F1-BC01 and 1C11-C5F1-BC10).

License

Apache-2.0. See LICENSE and NOTICE.

Metadata

Release files for ciencia-id 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ciencia-id 1.0.0
File Size Uploaded Provenance Actions
ciencia_id-1.0.0.tar.gz 8.4 kB With provenance Details for ciencia_id-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ciencia-id 1.0.0
File Interpreter ABI Platform Actions
ciencia_id-1.0.0-py3-none-any.whl Python 3 none any Details for ciencia_id-1.0.0-py3-none-any.whl

Total release size: 17.1 kB

Release files / ciencia_id-1.0.0.tar.gz

Download URL ciencia_id-1.0.0.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1e8ec69f8d4f4724636d893dc270e340cfe879220c54c5323461f9b760cc1068
BLAKE2b-256 checksum
How to use checksums
2c444dd144463e0cc2f065efc65370b146c4c9e3f09aea40a15ae7a6b89da3fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / ciencia_id-1.0.0-py3-none-any.whl

Download URL ciencia_id-1.0.0-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6638b8be267eafa272d15e12543a772d754ffbf0e61a8c8afeb50044c07edbaa
BLAKE2b-256 checksum
How to use checksums
e4ae4622551a1f9bfa35b3c34743cd447dff481f691c0706290fa58b9ae15ee1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Security for ciencia-id 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ciencia_id-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page