Phone Hash Directory

SHA-1, SHA-256, MD5 hash lookup for phone numbers

Country Code Reference Guide

Country Code Reference for Phone Hashing

Country codes are essential for international phone number formatting and hashing. They identify the country or region of a phone number and are required for E.164 format. This country code reference provides a lookup of common codes and explains how to use them for phone country codes in hash operations.

E.164 Country Code Structure

E.164 country codes are 1–3 digits, assigned by the ITU-T. The full E.164 number is: +[country code][national number]. The + indicates international format; when dialing, it is replaced by the international access prefix (e.g., 011 in the US, 00 in most of Europe).

Major Country Codes

Country Code Example (E.164)
United States +1 +15551234567
Canada +1 +14165551234
United Kingdom +44 +442071234567
Germany +49 +49301234567
France +33 +33123456789
Japan +81 +81312345678
China +86 +861012345678
India +91 +919876543210
Australia +61 +61212345678
Brazil +55 +5511987654321
Mexico +52 +5215551234567
Spain +34 +34612345678
Italy +39 +393201234567
Netherlands +31 +31201234567
South Korea +82 +821012345678

This is a subset; the full list includes 200+ countries and territories. Use a library (e.g., libphonenumber) for comprehensive country code lookup.

Shared Country Codes

Some codes are shared:

  • +1: North America (US, Canada, and many Caribbean nations use NANP)
  • +7: Russia and Kazakhstan
  • +44: United Kingdom (includes Crown dependencies with separate sub-codes)
  • +61: Australia (includes external territories)

National number format and length distinguish them. For hashing, use the full E.164 number—it is globally unique.

Country Code Lookup in Applications

When building phone hash pipelines, you may need to:

  1. Validate country code: Ensure the code exists and matches the national number length.
  2. Infer country: If the user provides a national format, infer the country from locale, IP, or explicit selection.
  3. Format for display: Convert E.164 to national format for UI (e.g., (555) 123-4567 for US).

Libraries like libphonenumber provide parse(), format(), and isValid() for these operations. See our international phone formatting guide.

Impact on Hash Consistency

For phone format hash operations, country code must be included consistently. Hashing 5551234567 (no country code) produces a different result than +15551234567. When integrating with our hash directory or reverse lookup, use E.164 with country code. Our systems normalize to this format.

Special Codes and Exceptions

  • +800, +808, +870, etc.: International freephone and shared cost. Format may differ.
  • +878: Universal Personal Telecommunications (rare).
  • Short codes: Country-specific (e.g., 411, 911 in US). May not use E.164; define project-specific rules.

Reference Implementation

For a complete country code list, consult:

  • ITU-T E.164 recommendation
  • libphonenumber metadata (embedded in the library)
  • ISO 3166-1 (country codes; note that ISO and E.164 are related but not identical)

When building a country code lookup table, include: country code, country name, expected national number length range, and any special rules (e.g., NANP area code validity). Validate that your table is updated when the ITU assigns new codes or changes existing ones. libphonenumber is maintained by Google and receives updates; prefer it over a static table you maintain yourself.

Country Code in Hash Keys

When designing database schemas or cache keys that include hashed phone numbers, consider whether to include country code as a separate field. For example, you might store {country_code: "+1", hash: "5d41402a..."} instead of only the hash. This enables filtering by country without reversing the hash, and can improve query performance when you need to scope lookups by region. The hash itself does not encode country—it's a function of the full E.164 string—so if you need country-level analytics, store it explicitly. When building dashboards or reports, country code enables filtering and aggregation without reverse lookup. For example, "how many hashes do we have per country?" is straightforward if country code is stored. If you only have the hash, you'd need to reverse lookup every record—expensive and often unnecessary if you can store country at ingestion time. Plan your schema with analytics in mind. At ingestion time, parse the E.164 number to extract country code (the digits between + and the national number). Store it in a separate column or field. Index it for efficient filtering. When building reports, aggregate by country code without touching the hash. This design supports both hash-based matching (for correlation) and country-level analytics (for reporting) without reverse lookup. Document the schema in your data dictionary. Include: field name, type, description, valid values (for country code: reference to E.164), and whether the field is required. Link to normalization and hashing documentation. When new engineers join, the data dictionary helps them understand the schema quickly. Keep it updated when you add or change fields. Consider using a schema registry or data catalog that supports documentation and versioning.

Summary

NANP and North American Numbering

The North American Numbering Plan (NANP) covers the US, Canada, and many Caribbean nations—all use country code +1. The full number is 10 digits (area code + exchange + subscriber). When normalizing, ensure you don't double the country code: 15551234567 should become +15551234567, not +115551234567. NANP numbers are a common source of normalization bugs.

Special Service Codes

Some codes are reserved for special services: +800 (international freephone), +888 (US toll-free), +900 (US premium). Format and validation may differ. For standard geographic numbers, E.164 applies. For special services, consult ITU-T documentation or your library's support. When in doubt, validate with libphonenumber before hashing.

Summary

Country codes are 1–3 digits that identify the country in E.164 format. Use them consistently for phone country codes lookup and hashing. For full international formatting guidance, see our international phone formatting guide. To perform hash lookups with properly formatted numbers, visit /hashes and /phones.

Explore Phone Hash Directory