Elysia Tools

Browse tools, examples, visual explainers, and topic guides from one clear workspace.

Top Categories

Hubs

Language
ZHESPTRUFRDEEN

Elysia Tools

Navigation

Validation

UPC/EAN arithmetic with synthetic codes

Three runnable Python fixtures test check digits, rejection and leading zeros without assigning products or companies.

Samples

Entries inside this sample collection

CodepythonSimple

Generate check digits

Run the generator for 7-, 11- and 12-digit synthetic bodies.

python
# Synthetic arithmetic fixtures only; no GS1 assignment or product claim.
def check_digit(body: str) -> str:
    if len(body) not in (7, 11, 12) or not body.isascii() or not body.isdigit():
        raise ValueError("Expected 7, 11 or 12 ASCII digits")
    total = sum(int(c) * (3 if i % 2 == 0 else 1)
                for i, c in enumerate(reversed(body)))
    return str((-total) % 10)

def valid(code: str) -> bool:
    return (len(code) in (8, 12, 13) and code.isascii() and code.isdigit()
            and check_digit(code[:-1]) == code[-1])

bodies = ["0000001", "00000000001", "000000000001"]
codes = [body + check_digit(body) for body in bodies]
assert codes == ["00000017", "000000000017", "0000000000017"]
assert all(valid(code) for code in codes)
print([len(code) for code in codes])  # [8, 12, 13]
CodepythonIntermediate

Reject altered controls

Run the validator against the original code, an altered check digit, a short string and a letter.

python
# Synthetic arithmetic fixtures only; no GS1 assignment or product claim.
def check_digit(body: str) -> str:
    if len(body) not in (7, 11, 12) or not body.isascii() or not body.isdigit():
        raise ValueError("Expected 7, 11 or 12 ASCII digits")
    total = sum(int(c) * (3 if i % 2 == 0 else 1)
                for i, c in enumerate(reversed(body)))
    return str((-total) % 10)

def valid(code: str) -> bool:
    return (len(code) in (8, 12, 13) and code.isascii() and code.isdigit()
            and check_digit(code[:-1]) == code[-1])

good = "000000000017"
bad = good[:-1] + "8"
assert valid(good)
assert not valid(bad)
assert not valid("00000000001")  # wrong complete-code length
assert not valid("00000000001A")  # not ASCII digits
print("one valid code; three invalid controls")
CodepythonIntermediate

Preserve leading zeros

Remove only ordinary display spaces, then compare string storage with integer conversion.

python
# Synthetic arithmetic fixtures only; no GS1 assignment or product claim.
def check_digit(body: str) -> str:
    if len(body) not in (7, 11, 12) or not body.isascii() or not body.isdigit():
        raise ValueError("Expected 7, 11 or 12 ASCII digits")
    total = sum(int(c) * (3 if i % 2 == 0 else 1)
                for i, c in enumerate(reversed(body)))
    return str((-total) % 10)

def valid(code: str) -> bool:
    return (len(code) in (8, 12, 13) and code.isascii() and code.isdigit()
            and check_digit(code[:-1]) == code[-1])

display = "0000 0000 0017"
code = display.replace(" ", "")  # explicitly allow ordinary spaces only
assert code == "000000000017" and valid(code)
assert len(code) == 12
assert str(int(code)) == "17"
assert not valid(str(int(code)))
print("keep identifiers as strings: 12 characters, not 2")

Tools

Tools frequently paired with this sample

Related

Related sample collections

Related

Related workflows

Tool usage guide

Sample-focused context for search and workflow understanding

Overview

Three runnable Python fixtures test check digits, rejection and leading zeros without assigning products or companies.

Verified exercises

Three runnable Python fixtures test check digits, rejection and leading zeros without assigning products or companies.

How it works

  1. 1Run the generator for 7-, 11- and 12-digit synthetic bodies.

Edge cases & common failures

  • Scope

    Arithmetic only. Synthetic codes must not label real products or imply ownership.

Examples

1. Generate check digits

How to use

Run the generator for 7-, 11- and 12-digit synthetic bodies.

Outcome

Generated codes have lengths 8, 12 and 13, all with check digit 7; all three pass the local checksum.

2. Reject altered controls

How to use

Run the validator against the original code, an altered check digit, a short string and a letter.

Outcome

One passes and three fail. Checksum success is not a GS1 assignment or product authenticity check.

3. Preserve leading zeros

How to use

Remove only ordinary display spaces, then compare string storage with integer conversion.

Outcome

The valid 12-character string becomes the invalid 2-character string 17 if converted to an integer.

Hub

Product, Publication, and Logistics Code Validation

Check ISBN, UPC/EAN/GTIN, and carrier tracking identifiers for supported formats and available check digits before a catalog or shipment handoff.

Hub

Batch Audio Library Cleanup and Delivery

Take a pile of mixed audio files to one shippable library — find and judge duplicates, convert the whole batch to a single format with deliberate encoder settings, fix the CBR or VBR bitrate policy, repair tags and filenames in bulk, and correct playback speed without touching pitch.

Hub

Application Field Policy Validation

Define and test product-owned password and color-code rules while separating application allowlists and ranges from generic validator results.

Hub

Single-Workbook XLSX Cleaning and Field Mapping

A focused workflow for one workbook or one worksheet: select a range, map headers, convert the cleaned table to JSON, and review source, type, null, and duplicate behavior without expanding into batch ingestion or warehouse delivery.

Home
Tools3215
Samples593
Visualizations472
Viewers103
Hubs239
Tags333
Images, Audio & Video657

Image, audio, and video processing, conversion, and optimization tools

Math, Date & Finance647

Calculators, numerics, date logic, statistics, and finance tools

Design & Color298

Color, layout, graphics, visual styling, and design helper tools

Text & Writing209

Writing, cleanup, formatting, extraction, and text analysis tools

Developer & Web194

Developer utilities, networking, web debugging, and automation helpers

Conversion & Encoding175

Format, file, archive, unit, and encoding conversion tools

Lead Generation Quiz Launch and Contact Handoff
Memorial Drafts: Family Review and Print Handoff
Private Habit Records: Backup, Restore and Sharing Review
Article to X and LinkedIn Drafts: Fact Review and Handoff
Markdown Interactive Deck Review and Offline Handoff

© 2026 Elysia Tools. All rights reserved.

DocsPricingAboutTerms of ServicePrivacy PolicyCookiesContact

Media

MOV to MP4 Converter

Convert MOV video files to MP4 format

Media

MP4 to MOV Converter

Convert MP4 video files to MOV format

Media

Stream Smart Remux

Rewrap media containers with stream copy.

Media

Batch Video Converter

Convert multiple video files between different formats like MP4, WebM, MKV, AVI, MOV with quality settings and batch processing

Media

Video to GIF Optimized

Convert videos to optimized GIF format with advanced compression settings

Media

Video Cutter

Cut and trim video clips with precision, supporting multiple formats and quality settings

Media

Video Horizontal Flip

Flip video horizontally (mirror left-right) while keeping original container format and copying audio stream when possible

Media

Video Stream Extractor

Extract audio and/or video streams from a video file using stream copy (no transcoding) after probing stream availability

Code Processing

Code Comment Samples

Sample code files with various comment styles for testing comment removal

Document

ICS calendars: UTC, all-day and recurrence fixtures

Three original downloadable iCalendar files use synthetic events and reserved example.com identifiers.

Validation

EIN mask examples

Compare three bounded input-and-output exercises. Each card includes its operation and exact expected result; the displayed source is not executed by this guide. New synthetic fixtures only. Bracketed labels and letter masks are intentionally unusable as identifiers or credentials. Do not replace them with real values. Results verify the stated text operations, never identity, issuance or authorization.

Validation

SSN mask examples

Compare three bounded input-and-output exercises. Each card includes its operation and exact expected result; the displayed source is not executed by this guide. New synthetic fixtures only. Bracketed labels and letter masks are intentionally unusable as identifiers or credentials. Do not replace them with real values. Results verify the stated text operations, never identity, issuance or authorization.

Python

Web File Operations Python Samples

Web Python file operations examples including text file read/write, file copy/move, directory traversal, and file validation

Text Processing

Duplicate Line Samples

Sample files with various types of duplicate lines for testing duplicate removal tools