age icon indicating copy to clipboard operation
age copied to clipboard

Add --inspect flag

Open jamespwilliams opened this issue 1 year ago • 1 comments

Fixes #56.

$ cat recipients.txt
age1lz0vhyg9y3k880cqscuh4hyfv0xdl7qnjqrlcz8euxc4a5d6eagsjhl6vc
age17hxnhlkq9ewhq594s3jf8c2e36n7gfg5mvefn0f3jqsfk76m6geszmywxr
age1ll9j2fr6nsdzmnqwk8qru9nx20sj264978jwswpnwq0nwnj4ayrsyugyqx
age160amxp02vl8w5e4z5tvvcmpdtjhdzkh20s3r9gqtzwufgyucreyqm6vw0y
age1xlauzza8tgn6l7e3ympwkps8tnt9psmpjj6jl0qfnfwkxkn7l4ws3s9xar

$ echo 'Hello age' | go run ./cmd/age -a -R recipients.txt -o encrypted.age.ascii

$ go run ./cmd/age --inspect encrypted.age.ascii | jq .
{
  "RecipientCounts": {
    "X25519": 5
  },
  "Version": "age-encryption.org/v1",
  "PayloadSize": 42
}

I've chosen to make the output JSON-encoded because the data that --inspect outputs is fairly small, so the JSON is fairly easily readable (even without jq), and outputting in JSON makes it machine-readable.

I've read https://github.com/FiloSottile/age/blob/9f0a2d25ac79da8100d68f3e8b3a1a57ea4a73ba/.github/CONTRIBUTING.md and can confirm that I won't be offended if this is reimplemented instead of being merged :smile:

jamespwilliams avatar Apr 30 '23 14:04 jamespwilliams

Thank you for writing this. I used this feature to test some tooling that uses age, and it came in very handy.

digtail avatar Jul 06 '23 22:07 digtail