HACKER Q&A
📣 erehweb

Best way to encode Wordle words? rot13 is too revealing


What's the best simple way to encode Wordle's 5-letter solutions? Go-to would normally be rot13, but that reveals a lot about the word - e.g. if it has any repeated letters.


  👤 ArtWomb Accepted Answer ✓
This is actually a really good problem. How to keep secrets in javascript from browser clients? Most simply don't bother and store every thing server side. But for games like wordle, if you wanted it to be pro level multiplayer competitive, you'd need some punk-busting tech in there ;)

👤 laurieg
Base 64 encoding is good enough to hide a keyword from a casual glance

👤 josefdlange
For simple sharing without giving it away, what about a RotN where N starts at an arbitrary value (13, for example) but increments for each successive character?

ALPHA

becomes

NZEXR

This way, repeats become opaque. Seems clear enough to share in the clear where _breaking_ the cipher isn't a big concern, just immediately recognizing the answer or patterns in it, is.


👤 speedgoose
Let's be totally overkill and use AES-256-GCM with Json Web Encryption.

https://datatracker.ietf.org/doc/html/rfc7516/


👤 pajko
https://www.dcode.fr/vigenere-cipher

Choose an arbitrary length plaintext (8-10 characters would suffice), encode it with the given word as the key.


👤 willcipriano
Do you need the whole solution or just a way to validate answers against them? The first n characters of a hash would work for the latter. For the former I'd encode it into something like base-122[0] or something else equally esoteric.

[0]http://blog.kevinalbs.com/base122


👤 soulofmischief
Maybe you could implement a provably-fair system similar to bitZino?

It just uses SHA256, you share the hash and at any later time prove fairness by letting the user rehash the secret themselves to compare against the original.

Provably Fair Shuffling Through Cryptography

https://archive.is/qwImN


👤 dantetheinferno
Wouldn't you want to not give the client any information about the correct answer? I would think you would want to have a `POST` command that gives you the encoding guesses if you truly want to keep it out of the browser.

👤 LinuxBender
Maybe something similar to txtmode? [1] One could limit the dictionary to 5 letter words.

[1] - https://github.com/c9fe/txtmode.git


👤 throwaway889900
You could probably just split the word up with random gibberish letters in between. Easy enough to write and takes time to figure it out if there's any pattern.