← Cryptography guide

K091 / Encoding and decoding

Punycode

Punycode IDN · Survey date 2026-12-05

Punycode is an ASCII-compatible transfer encoding syntax for IDNA.

CRYPTOGRAPHY LAB / K091

Cryptography Lab · Punycode

Run real computations and inspect intermediate states step by step.

Educational only. Never enter real passwords or secret keys. Computation stays in your browser; input and trace values are not sent to a server. Do not use this implementation in production.

Scope: Limited implementation

Punycode (RFC 3492 Bootstring; no IDNA validation)

See the scope above for fixed examples, reduced parameters and supported variants. Standard operation names and formulas are retained.

Reference ↗

Open lab →

Definition and overview
Punycode is an ASCII-compatible transfer encoding syntax for IDNA. Source document ↗
Classification and reversibility
Reversible transfer encoding, distinct from encryption and hashing. Source document ↗
Key or secret requirements
Not confirmed in the survey
Operating principle and structure
Retains basic ASCII and represents non-ASCII using ASCII characters permitted in hostnames. Source document ↗
Key size, block size and parameters
An instance of Bootstring with document-defined parameter values. Source document ↗
Security strength and recommendation
Inconsistent IDN interpretations can route the same name to different servers, creating security issues. Source document ↗
Known attacks and vulnerabilities
Some idna implementations accepted labels that produced no non-ASCII characters, causing ASCII/root-label masking and comparison inconsistencies. Source document ↗
Standards and certification
Implementations follow IDNA2008 (RFC 5890–5893). Source document ↗
Typical uses
ASCII-compatible label representation for internationalized domain names. Source document ↗
Implementations, libraries and tools
Punycode.js and other RFC 3492/IDNA libraries. Source document ↗
Decryption or decoding
Decode ASCII Punycode labels into Unicode strings, represented in UTF-8 where needed. Source document ↗
Advantages
Simple, efficient transfer encoding suited to IDNA. Source document ↗
Limitations and cautions
Does not guarantee the shortest representation; ASCII labels including xn-- must fit DNS's 63-byte limit. Source document ↗
Distinguishing encryption, encoding and hashing
Keyless reversible transfer encoding with no confidentiality. Source document ↗

Practical examples

Examples are illustrative; they are not execution-tested implementations or operational recommendations.

Example

A Unicode domain label may become an ASCII label beginning xn-- after Punycode/IDNA processing. Resolve DNS using ASCII and decode for user display.

Procedure

Encode Unicode labels according to IDNA, adding xn-- when needed; decode xn-- labels with Punycode. This is reversible encoding, not encryption.

Scenario

Convert user input to A-labels for DNS and certificate processing, restore U-labels for display. Combine confusable/mixed-script checks and IDNA2008 validation to combat phishing.

Pitfalls and alternatives

No secret key or confidentiality. Check DNS's 63-byte limit, xn-- prefix, normalization differences across IDNA versions, homographs and masking. Use vetted IDNA libraries.

References