Dev.to AI 🤖 Ai 👁 0 📖 2 min read

Reverse-Engineering China's 18-Digit Enterprise Code (USCI): Building a Corporate Fraud-Detection Engine

Every year, global e-commerce importers and hardware startups lose substantial deposits to fraudulent suppliers or shell corporations in China. When foreign buyers request a business license (营业执照), bad actors frequent

Every year, global e-commerce importers and hardware startups lose substantial deposits to fraudulent suppliers or shell corporations in China.

When foreign buyers request a business license (营业执照), bad actors frequently photoshop an 18-digit Unified Social Credit Identifier (USCI / 统一社会信用代码).

In this article, we’ll break down the mathematical specification of the USCI code, implement the official GB 32100-2015 checksum algorithm in Python, and explain how we structured an automated due diligence risk scoring pipeline.

1. Deconstructing the 18-Digit USCI Format

Under China's National Standard GB 32100-2015, every legally registered legal entity receives an 18-character alphanumeric string structured into 5 logical segments:

 9  1  4 4 0 3 0 0  M A 5 F X 1 2 3  X
└─┘└─┘└──────────┘ └───────────────┘ └─┘
 1  2      3               4          5

1. Registration Authority (1 char: e.g., 9 = Market Regulation / SAMR)
2. Entity Type (1 char: e.g., 1 = Enterprise, 2 = Individual Business)
3. Administrative Region Code (6 chars: 440300 = Shenzhen, Guangdong)
4. Organization Code (9 chars: The unique institutional body identifier)
5. Check Digit (1 char: Calculated via MOD 31-3 checksum)

2. Implementing the MOD 31-3 Checksum in Python

The 18th character is not random. It is calculated using a weighted modulus algorithm over a base-31 character set (excluding vowels I, O, Z, S, V to avoid optical confusion with numbers 1, 0, 2, 5):

import re

# Base-31 Character Set and Weights
CHAR_SET = "0123456789ABCDEFGHJKLMNPQRTUWXY"
CHAR_MAP = {c: i for i, c in enumerate(CHAR_SET)}
WEIGHTS = [1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28]

def validate_usci(usci: str) -> bool:
    """
    Validates an 18-character Chinese Unified Social Credit Identifier (GB 32100-2015).
    """
    if not usci or len(usci) != 18:
        return False

    usci = usci.upper()
    if not re.match(r"^[0-9A-HJ-NP-RT-UW-Y]{18}$", usci):
        return False

    # Calculate weighted sum of the first 17 characters
    total_sum = sum(CHAR_MAP[usci[i]] * WEIGHTS[i] for i in range(17))

    # MOD 31-3 Formula
    remainder = total_sum % 31
    check_index = (31 - remainder) % 31
    expected_check_digit = CHAR_SET[check_index]

    return usci[17] == expected_check_digit

# Test with a real verified enterprise code
print(validate_usci("91440300MA5FX1234X")) # Returns True/False

If a prospective supplier emails you a PDF license where the 18th digit fails this mathematical check, it is a 100% counterfeit document.

3. Beyond Regex: The Risk Scoring Pipeline

A valid license number does not guarantee a safe supplier. In our production pipeline, we cross-reference the USCI against three public registry vectors:

[USCI Code] ──> SAMR Database ────> Registered vs. Paid-in Capital
            ──> Supreme Court ────> Blacklisted Debtors (失信被执行人)
            ──> Trademark Office ─> Genuine OEM Brand Ownership

Critical Risk Flag: The Paid-in Capital Discrepancy

China operates on a "Subscribed Capital" system. An entity can register with $10,000,000 in registered capital while contributing $0 in actual paid-in capital. If their balance sheet collapses, foreign creditors have no legal recourse.

4. Automated Cross-Border Verification

Building and maintaining scrapers against government CAPTCHAs and state-level registries requires constant maintenance.

To help foreign buyers and procurement engineers verify Chinese entities instantly without navigating Chinese-language portals, we built ChinaSupplierScan.

Using ChinaSupplierScan, you can enter any vendor name or USCI to instantly inspect:

  • Legal registration status and actual paid-in capital
  • Official court enforcement orders and frozen asset history
  • Operating anomalies and manufacturing scope verification

Have you ever built automated data verification pipelines for international regulatory registries? Share your experiences in the comments!

📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.