K087 / Encoding and decoding
URL percent-encoding
A URL encoding scheme representing arbitrary data in URIs using only permitted US-ASCII characters.
CRYPTOGRAPHY LAB / K087
Cryptography Lab · URL percent-encoding
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.
URI component percent-encoding
See the scope above for fixed examples, reduced parameters and supported variants. Standard operation names and formulas are retained.Output
Previous state
- Definition and overview
- A URL encoding scheme representing arbitrary data in URIs using only permitted US-ASCII characters. Source document ↗
- Classification and reversibility
- Reversible string encoding and decoding. Source document ↗
- Key or secret requirements
- Not confirmed in the survey
- Operating principle and structure
- Represents each byte as a percent sign followed by two ASCII hexadecimal digits. Source document ↗
- Key size, block size and parameters
- Not confirmed in the survey
- Security strength and recommendation
- Not confirmed in the survey
- Known attacks and vulnerabilities
- Multiple encoding and interpretation differences can enable validation bypasses and confusion attacks. Source document ↗
- Standards and certification
- Related to RFC 3986 and application/x-www-form-urlencoded. Source document ↗
- Typical uses
- Represent spaces and special characters in URLs, queries and form data. Source document ↗
- Implementations, libraries and tools
- Language libraries such as Python urllib.parse.unquote. Source document ↗
- Decryption or decoding
- Decode %HH sequences back to hexadecimal byte values. Source document ↗
- Advantages
- Keeps URL strings textual even with special or nonprinting characters. Source document ↗
- Limitations and cautions
- RFC 3986 and URL-standard percent handling can differ between implementations. Source document ↗
- Distinguishing encryption, encoding and hashing
- URI representation encoding, not encryption or hashing. Source document ↗
Practical examples
Example
Convert input bytes to %HH for insertion into a URL/URI component. Decode the sequences into bytes and interpret them using UTF-8 or the specified charset. No secret is used.
Procedure
Encode: convert to bytes in the target charset (usually UTF-8), distinguish reserved and unreserved characters, replace required bytes with %HH. Decode: restore bytes and interpret the specified charset. This is keyless reversible conversion, not encryption.
Scenario
Use for special characters in search terms/path parameters and form submissions. Servers should revalidate path/query boundaries after decoding to prevent bypasses.
Pitfalls and alternatives
Beware plus versus space, %20 versus +, double encoding, malformed percent sequences and component-specific reserved characters. Validate normalized decoded values; use encryption, signatures or hashing separately for security.
References
- Percent-encoding ↗
- URI - Crystal 1.23.0-dev ↗
- URL Standard ↗
- CAPEC - CAPEC-72: URL Encoding (Version 3.9) ↗
- Percent-encoding - Glossary | MDN ↗
- urllib.parse — Parse URLs into components — Python 3.15.2 documentation ↗
- url package - net/url - Go Packages ↗
- URL confusion vulnerabilities in the wild: Exploring parser inconsistencies ↗
- percent_encoding_rfc3986 - Rust ↗