Shared data even we can't read: browser encryption with the key after the # in an invite link

Squad Island is a browser game on our site where you type in your friends' names and they live on a little island. Its "shared island" mode, released on October 21, 2026, lets a group of friends play on one island together. The island holds things about real friends: their names, faces drawn with a finger, catchphrases.

So the island is encrypted on the player's device before it's stored on our server, and the key lives only after the "#" in the invite link. Browsers don't send that part to the server. The server only holds ciphertext, so we, the people running the site, can't read anyone's island.

Here's how it works, with the key parts of the real code. The crypto itself turned out to be the easy part. Most of the work went into everyone writing to the same data, keeping old tabs from erasing new data, and being honest about what this design can't protect. This describes the implementation as of October 23, 2026.

Why "unreadable even to us"

Our tools have always promised not to send what you enter anywhere. That used to be an absolute rule for the whole site. But sharing an island with friends means storing data somewhere.

On October 21, 2026, we changed the rule: sending data isn't banned, but the page and the privacy policy must say what is stored, why, and for how long. The tools still don't send your input, and an automatic check before every release still makes sure no network code sneaks into them.

If we send it, we send it unreadable. Three reasons:

  1. It's about real friends. There's no reason for us to be able to read their names or drawn faces.
  2. Readable data means more to protect and more damage if it leaks. If our database leaked, ciphertext without keys reveals nothing.
  3. The explanation is short and clear. The privacy policy can simply say we can't read island contents.

What we gave up: the server can't search, aggregate or validate contents. Bad data has to be caught by the reading client (more below). To see how the game is played, we count only the kinds and numbers of actions, separately from island contents.

The overall design

An invite link looks like this:

/games/uchira-shima/#s=<22-char island ID>.<43-char key>

Part What it is Reaches the server?
Island ID 16 random bytes Yes (to find the island)
Key 32 random bytes (256 bits) No (it's after the #)
Delete token 16 random bytes, kept only on the creator's device (not in the link) Once, at creation. The server stores only its hash

The part of a URL after "#" (the fragment) was meant for pointing to a spot within the page. Browsers leave it out of page requests and out of the Referer sent when you navigate elsewhere, so it doesn't appear in server access logs either. We use that to keep the key only in the hands of people who have the link.

  1. Creator: the device makes the ID, key and delete token → encrypts the island → sends ID and ciphertext → builds the invite link to send to friends in a chat app
  2. Invited friend: opens the link → the page reads the ID and key after "#" → fetches the ciphertext by ID → decrypts and shows the island
  3. Every action: re-encrypt and send. Friends' screens check for a new version every 15 seconds and when the tab comes back into view

Making the key

// Creating an island (all on the device; key parts only)
const id = randId(16);                                  // island ID: 16 random bytes -> 22 chars
const raw = crypto.getRandomValues(new Uint8Array(32)); // key: 32 random bytes (256 bits)
const owner = randId(16);                               // delete token: only the creator's device has it
const key = await crypto.subtle.importKey('raw', raw, 'AES-GCM', false, ['encrypt', 'decrypt']);
// The server only gets the ID, ciphertext, delete token and format version
await post({ op: 'create', id, blob: await seal(key, island), owner, fmt: FORMAT });
// Invite link: the key goes only after the #
const url = location.origin + location.pathname + '#s=' + id + '.' + toUrl(u8b64(raw));

Random values come from crypto.getRandomValues (cryptographically secure), never Math.random. The ID and key are encoded as base64url so they can go straight into a URL: 16 bytes become 22 characters, 32 bytes become 43.

The false passed to importKey makes the key object non-extractable. To be honest, though, the raw key bytes also exist as text in the invite link and in this device's storage, so this isn't much of a defense (see "What this can't protect").

The delete token is sent once, at creation. The server stores its SHA-256 hash, not the token itself, the same idea as storing password hashes.

Encrypting and decrypting

async function seal(key, data) {
  let body = new TextEncoder().encode(JSON.stringify(data)), flag = 0;
  if (window.CompressionStream) { body = await gz(body, false); flag = 1; } // gzip first
  const pt = new Uint8Array(body.length + 1), iv = crypto.getRandomValues(new Uint8Array(12));
  pt[0] = flag; pt.set(body, 1);                         // first byte = compressed or not
  const ct = new Uint8Array(await crypto.subtle.encrypt({ name: 'AES-GCM', iv }, key, pt));
  const out = new Uint8Array(12 + ct.length);
  out.set(iv); out.set(ct, 12);                          // prepend the 12-byte IV
  return u8b64(out);
}
async function unseal(key, b64) {
  const all = b64u8(b64);
  const pt = new Uint8Array(await crypto.subtle.decrypt(
    { name: 'AES-GCM', iv: all.subarray(0, 12) }, key, all.subarray(12)));
  const body = pt[0] === 1 ? await gz(pt.subarray(1), true) : pt.subarray(1);
  return JSON.parse(new TextDecoder().decode(body));
}

Remove the "#" from the address bar right away

// A tiny script at the very top of the game's HTML (key parts only)
var h = location.hash;
if (h.indexOf('#s=') === 0) {
  window.__SHIMA_INVITE = h.slice(1);                                  // hand it to the game
  history.replaceState(null, '', location.pathname + location.search); // remove it from the address bar
}

A tiny script at the very top of the game's HTML picks up the fragment and removes it with history.replaceState, so a URL containing the key doesn't stay on screen.

Once opened, the island is saved in localStorage as one of the islands this device knows (ID, key, which resident you are, and the delete token if you created it), so it opens next time without the link.

One snag: on iPhone, Safari, the browser inside the LINE chat app, and a home-screen web app each have separate storage. If someone opens the invite link in LINE and then adds the game to the home screen, the home-screen copy can't find the island. So on the first launch from the home screen, we point people to island settings to paste the invite link or use a transfer code. With keys kept on the device, "not visible in another browser" can't be avoided.

What the server holds

The server is Cloudflare Pages Functions with D1 (SQLite). Each island is a single row:

Column Contents
id Island ID (random)
v Update count (version)
blob Ciphertext (base64)
owner SHA-256 hash of the delete token
created / updated Timestamps
fmt Content format version (below)

Names, faces, catchphrases and diaries are all inside blob, unreadable to the server.

The server also keeps two other things. One is a record of whether islands keep being played: for each day with writes, the date, that day's write count and the island's creation date. It's keyed not by the island ID but by an irreversible value mixed with a secret, and deleted once it is 400 days old (or when the creator deletes the island). The other is an irreversible value derived from the IP address, used to count writes per hour to stop floods; counts older than 2 hours are removed at the next cleanup.

Update, November 6, 2026: that play record has since gained fields. It now also holds how many residents visited the island that day and how many have visited so far (counts only, not who). When an island is created, it also records which kind of link its creator first arrived from and whether it was the Japanese or English version. The play counts gained the same kind-of-link value on October 28. The current list is on the game's privacy page.

An automated test checks that it's really encrypted. It drives a real browser to create an island and play, including a second device joining by invite, then checks that no resident's name appears in the request bodies reaching the test server or in the base64-decoded ciphertext bytes. The same test checks that names don't appear in invite links or usage-count requests.

Everyone writing to one island (versions)

Several people may act at once, so we need to stop A's change from being overwritten by B. Some systems merge changes on the server, but ours can't read contents, so it can't merge. We chose the simplest approach: each write carries the version the client has, and only succeeds if that equals the island's latest.

-- Write only if the client's version (base) equals the island's latest,
-- and the client's format version (fmt) is not older than the island's
UPDATE shima_islands SET v = v + 1, blob = ?1, updated = ?2, fmt = ?5
 WHERE id = ?3 AND v = ?4 AND fmt <= ?5
-- If no row changed, return 409 with the island's latest { v, blob, fmt }

If someone wrote first, the server returns 409 with the latest ciphertext. The screen reloads it and says, roughly, "Someone else moved at the same time, so we reloaded the island. Try again." Your action is lost. That trade-off assumes friends rarely act in exactly the same few seconds.

Polling every 15 seconds also sends the client's version. If nothing changed, the server replies with no body (204), so it doesn't resend the whole ciphertext every time.

Testing found a bug (October 22, 2026). The write made when the day changes (the day's island news and so on) put two devices with very different clock dates into a loop, each rewriting the other's date, two writes per second between them. The cause was a mismatch between the other device's date and a safeguard that keeps the island's date within 30 days of today. Now the day-change write is limited to twice per island per day. Because the server can't read contents, conflicts like this happen between clients and can only be stopped on the client side.

Old tabs erasing new data (format versions)

Anyone with the invite link can rewrite the island, so the client validates every field on load and drops unknown fields and bad values.

That caused trouble when adding features. Say a new release adds a field to a resident's appearance. An old tab still open, or an old cached offline copy, drops that field as unknown. If it then writes, the new field disappears from the island, and the server can't stop it because it can't read contents.

So the content format got a version number (fmt):

We added fmt on October 22, 2026. That same day we added island names, duo names, private settings and a "visited" stamp, and the version went up to 5. Without fmt, each addition risked old tabs erasing the new fields.

Additions that old clients don't drop can go in without a version bump. For example, a new "surprise" story in the island news doesn't need one, because old clients don't discard unknown story numbers on load.

Deleting (creator only, 120 days)

What this can't protect

"Unreadable even to us" sounds good, but the limits matter just as much. These are the ones we know of.

1. Anyone with the link can read and change the island

The key is the invite link. If the link is forwarded outside the group, that person can get in. There's currently no way to rotate the key, so if a link spreads, the creator's only option is to delete the island. The link also stays in the chat where it was sent. The transfer code for moving to a new phone contains the key too, so it needs the same care as the link.

2. It's readable on the device

The key and the decrypted copy used for display are in the browser's storage. Anyone who can use that device, or any script running on the same site, can read them. On-device encryption protects against reading from the server side; it doesn't protect the device. So we're careful about adding third-party scripts to the same site, and are considering moving the island to its own subdomain.

3. We ship the client code

This is a fundamental limit of on-device encryption in web apps. We could technically change the code to send the key to the server. So "we can't read it" means "with the code we ship now, the key never reaches the server", nothing more. The client code is public, so anyone can inspect it.

4. What encryption doesn't hide

5. The server can't validate contents

Bad contents can't be stopped on the server, so the reading client has to check. Right now the client validates each field, caps decompressed size, avoids key names with special meaning, and keeps the island's date from jumping too far ahead.

What we wrote in the privacy policy

The Squad Island section of our privacy policy says, in short, that the key exists only after the "#" in the invite link, browsers don't send that part to our server, and so we can't read island contents. We tried to:

The English version of the game has its own privacy page with the same content.

Looking back

The encrypt and decrypt parts took a few dozen lines with the Web Crypto API and no libraries.

The work was in the problems that come from the server not being able to read anything: simultaneous writes, old tabs, tampered contents, islands invisible in other browsers. None can be fixed by the server looking at the data, so each had to be decided up front as a rule between clients.

And "unreadable even to us" is easy to use as a slogan, but without describing the limits with equal weight, it misleads. That's why this note and the privacy policy go all the way down to the limits.

Squad Island runs in a phone or desktop browser with no sign-up. You start on a trial island, and once you type in your friends' names you can make your own shared island. → Play Squad Island

Nandemo Factory is a one-person studio in Japan that makes small browser games, with AI doing most of the work. We only write about things we built and checked ourselves, with the numbers we actually saw. Play the games in English.

Related notes