Skip to main content

diffseek - A tool for comparing long strings across devices via binary search

Project description

This is a tool for diffing long strings. It helps when you have to physically transcribe a long string (e.g. a token) from one box to another, which comes up surprisingly often when I'm using Qubes. The intended usage contexts are:

  1. Airgapped systems
  2. Low-privilege systems without e.g. email access.

But in general it is useful whenever you have two copies of a string, on two devices, and you want to quickly determine whether they are identical (and efficiently find and correct any differences).

You run diffseek on both devices, enter the reference string on the first device, enter your best-effort transcription into the second device, then compare a series of generated values across devices, indicating when they match or don't. These are used by diffseek to conduct a binary search for differences between the two strings. At every step the string is printed out, with any potentially differing regions written in orange.

For example:

  • Maybe you receive a login link for an online account by email, but you want to use the link on a different computer which has no email access.
  • You might copy the link by hand. However, this is error-prone, especially with the long hex string likely included in the URL.
  • In such a case, you'll start by running diffseek on both devices.
    • On the first device, you paste the string in (this happens interactively, keeping your secret value out of your shell history).
    • The string is hashed and some values are derived: a phrase, a color, etc. These are all derived from the hash. All of these are printed out in a single row.
    • On the second device, make your best attempt to copy the string over. This device will hash this string and derive values from it as well.
    • Then, on both devices, press Enter. This triggers diff mode, where differences are identified via binary search.
      • In diff mode, the tool firsts reports the length of your string, and then asks if you would like to target a different length, allowing you to input it if so.
      • Then, a binary search is started. First, the first half of the string (measuring from the target, not actual, length) is hashed and values are derived or shown. Then the user indicates whether these values match the ones seen on the other system.
      • Whenever two hashes match, this indicates that the hashed area is free of errors. By binary search we can narrow down the positions of potential errors.
      • At every step, we can re-print the user-provided string, with sections colored differently by whether they're possible errors (orange), definite errors (red), or known-good (white).
      • We order the search breadth-first so that we can quickly rule out large matching regions of each string.
      • There should be an option to restart the search, which would be useful after we fix an error.

DISCLOSURE: I wrote the description above and provided it to Claude Code, which wrote the corresponding implementation and test suite. I fixed a couple mistakes it made, tested it manually and found it to work as expected for my use case. Still, it is primarily an AI-written tool, if you care about that.

Usage: ./diffseek.py or python3 diffseek.py

Note: The above comment about BFS is now only true when both strings have target length; if the transcribed string has a different length then we want to prioritize finding the first difference, not all differences, for obvious reasons, and so we use DFS instead in this case.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diffseek-0.1.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

diffseek-0.1.0-py2.py3-none-any.whl (5.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file diffseek-0.1.0.tar.gz.

File metadata

  • Download URL: diffseek-0.1.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.4

File hashes

Hashes for diffseek-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2375f87b08c3f2952203387481bc5a705e13d964fca435166737080455545383
MD5 d17d94f3a722114c537527e0b412ab66
BLAKE2b-256 1eb0b4daa88d0581ab220557f1f97732b886e0e986308d17de5abade0666e93f

See more details on using hashes here.

File details

Details for the file diffseek-0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: diffseek-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.4

File hashes

Hashes for diffseek-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 57bfa7ea8d23f20cf72a58538f6a16bfe61506b82aef160fe2b0e4bee66e05f2
MD5 a5834347e490235c74113690ec0904ee
BLAKE2b-256 4144b865278284a408cb8e54ea199f5a672796112af8602dfc222513138feef4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page