Base85 RFC 1924 Encoder

Enter a non-negative whole number to encode.

How it is calculated

RFC 1924 writes an IPv6 address as a 128-bit integer in base 85. Digit values 0 to 84 map to 0-9, A-Z, a-z and then the 23 symbols !#$%&()*+-;<=>?@^_`{|}~. The tool reads the address (full, zero-compressed or with an embedded IPv4 part), takes its 16 bytes as one number, and divides by 85 twenty times; each remainder is one digit, and the digits in reverse order give the result. Because 8520 is larger than 2128, every address fits in 20 digits, and leading zeros are kept so the form is always 20 characters long, as section 6 of the RFC says.

Instead of an address you can enter a plain decimal integer from 0 to 2128 − 1 (integer mode, said so in the result); it is treated as the address value and also padded to 20 characters. Anything else, such as an invalid address, a negative number, a decimal point or 2128 and above, gives no result. The arithmetic is done on the 16 bytes, so no big-number library is needed.

Worked example

Encode the address from RFC 1924 itself, 1080::8:800:200C:417A. As a 128-bit integer it is 21932261930451111902915077091070067066. Dividing by 85 twenty times gives the remainders 51, 34, 65, 57, 58, 0, 75, 53, 37, 4, 19, 61, 31, 63, 12, 66, 46, 70, 68, 4; read from last to first and mapped to the alphabet they spell 4)+k&C#VzJ4br>0wv%Yp, exactly as the RFC prints it, 20 characters. A small value such as the integer 12345678 still takes 20 characters: 0000000000000000K8#N.

Try this example →

Common mistakes

  • Expecting a short result for a small value. The RFC form is always 20 characters, so the integer 1 gives 19 zeros and a 1.
  • Entering an address with a zone index or prefix length, such as fe80::1%eth0 or 2001:db8::/32. Only the address itself is accepted.
  • Confusing this with Ascii85. RFC 1924 uses a different alphabet and encodes the whole number as one value, not in 4-byte groups.
  • Expecting the output to be decodable without the alphabet. The same characters mean different values in other Base85 variants.
  • Typing the integer with thousands separators or in scientific notation. Only plain digits are accepted in integer mode.

Sources

About this calculator

Base85 encoding represents data using 85 printable characters instead of Base64's 64, packing more information per character: the same number comes out roughly 6% shorter than in Base64. RFC 1924 defines a specific Base85 alphabet (0–9, A–Z, a–z plus a set of punctuation symbols) originally proposed as a compact textual notation for IPv6 addresses. RFC 1924 treats the 128-bit address as one integer and writes it in base 85, always as exactly 20 characters with the leading zeros kept, because 8520 is just above 2128. This encoder takes an IPv6 address in any of its usual text forms (1080:0:0:0:8:800:200C:417A or 1080::8:800:200C:417A) and returns those 20 characters, 4)+k&C#VzJ4br>0wv%Yp for the RFC's own example. It also accepts a decimal integer below 2128, labeled as integer mode, which it reads as the address value.

While RFC 1924's IPv6 notation itself never saw wide adoption, its Base85 alphabet and encoding method remain useful in software engineering wherever a compact text representation of a number is needed — such as writing large numeric IDs more densely than Base64 allows. Developers working with base-conversion and encoding schemes use tools like this to verify their own RFC 1924 implementation or convert values by hand for debugging.

Was this helpful?

You can pick up to 3 reactions.

Note from the editors

RFC 1924 was written for IPv6, where every 128-bit address becomes exactly 20 characters, leading zeros included. The highest possible address, ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff, gives =r54lj&NUUO~Hi%c2ym0, still 20 characters. Which direction would be more useful to you next, decoding back to an address?

Comments

  • Be the first to comment.

Popular calculators

All Calculators