text/peek
- 578 bytes
- View raw
1#!/usr/bin/env python3
2"""
3This is a tiny script I can use to preview secrets on the command line.
5It prints the beginning and end of the secret, but not the whole thing --
6this avoids printing secrets in plaintext.
8 $ echo "$FLICKR_API_KEY" | peek
9 ae8…f3a
11"""
13import sys
16if __name__ == '__main__':
17 secret = sys.stdin.read().strip()
19 if not secret:
20 print("<empty>")
21 elif len(secret) < 4:
22 print(f"{secret[0]}…")
23 elif len(secret) < 12:
24 print(f"{secret[:3]}…")
25 else:
26 print(f"{secret[:3]}…{secret[-3:]}")