b64-clip 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
b64_clip-1.0.0/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Eric Joye
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,78 @@
1
+ Metadata-Version: 2.4
2
+ Name: b64-clip
3
+ Version: 1.0.0
4
+ Summary: Base64 encode/decode with clipboard, zero dependencies
5
+ Author: b64-clip contributors
6
+ License: MIT
7
+ Requires-Python: >=3.11
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Dynamic: license-file
11
+
12
+ # b64-clip
13
+
14
+ Base64 encode/decode with clipboard, zero dependencies.
15
+
16
+ Encode auth tokens, config values, certificate data, and more — result is
17
+ automatically copied to your clipboard.
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ pip install b64-clip
23
+ ```
24
+
25
+ Or run directly (no install):
26
+
27
+ ```bash
28
+ python3 b64_clip.py encode "hello world"
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ ```bash
34
+ # Encode a string
35
+ b64-clip encode "hello world"
36
+ # Output: aGVsbG8gd29ybGQ=
37
+ # (also copied to clipboard)
38
+
39
+ # Decode a string
40
+ b64-clip decode "aGVsbG8gd29ybGQ="
41
+ # Output: hello world
42
+ # (also copied to clipboard)
43
+
44
+ # Encode a file
45
+ b64-clip encode --file cert.pem
46
+
47
+ # Decode a file
48
+ b64-clip decode --file encoded.txt
49
+
50
+ # Pipe from stdin
51
+ echo "test" | b64-clip encode
52
+
53
+ # URL-safe base64 decode
54
+ b64-clip decode --url-safe "PDw_Pz4-"
55
+ ```
56
+
57
+ ## What it does
58
+
59
+ - **Encode**: Takes any input (string, file, or stdin) and outputs base64
60
+ - **Decode**: Takes base64 input and outputs the decoded plaintext
61
+ - **Clipboard**: Automatically copies the result to your clipboard on macOS,
62
+ Linux (xclip/wl-copy), and Windows (clip.exe)
63
+ - **Zero dependencies**: Python stdlib only — no pip install needed at runtime
64
+
65
+ ## Requirements
66
+
67
+ - Python 3.11+
68
+ - For clipboard support: `xclip` on Linux (install with `sudo apt install xclip`),
69
+ `pbcopy` on macOS (built-in), `clip.exe` on Windows (built-in)
70
+
71
+ ## Security
72
+
73
+ Nothing is logged or stored. The tool processes data in memory only and does not
74
+ write any temporary files or make network requests.
75
+
76
+ ## License
77
+
78
+ MIT
@@ -0,0 +1,67 @@
1
+ # b64-clip
2
+
3
+ Base64 encode/decode with clipboard, zero dependencies.
4
+
5
+ Encode auth tokens, config values, certificate data, and more — result is
6
+ automatically copied to your clipboard.
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ pip install b64-clip
12
+ ```
13
+
14
+ Or run directly (no install):
15
+
16
+ ```bash
17
+ python3 b64_clip.py encode "hello world"
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ```bash
23
+ # Encode a string
24
+ b64-clip encode "hello world"
25
+ # Output: aGVsbG8gd29ybGQ=
26
+ # (also copied to clipboard)
27
+
28
+ # Decode a string
29
+ b64-clip decode "aGVsbG8gd29ybGQ="
30
+ # Output: hello world
31
+ # (also copied to clipboard)
32
+
33
+ # Encode a file
34
+ b64-clip encode --file cert.pem
35
+
36
+ # Decode a file
37
+ b64-clip decode --file encoded.txt
38
+
39
+ # Pipe from stdin
40
+ echo "test" | b64-clip encode
41
+
42
+ # URL-safe base64 decode
43
+ b64-clip decode --url-safe "PDw_Pz4-"
44
+ ```
45
+
46
+ ## What it does
47
+
48
+ - **Encode**: Takes any input (string, file, or stdin) and outputs base64
49
+ - **Decode**: Takes base64 input and outputs the decoded plaintext
50
+ - **Clipboard**: Automatically copies the result to your clipboard on macOS,
51
+ Linux (xclip/wl-copy), and Windows (clip.exe)
52
+ - **Zero dependencies**: Python stdlib only — no pip install needed at runtime
53
+
54
+ ## Requirements
55
+
56
+ - Python 3.11+
57
+ - For clipboard support: `xclip` on Linux (install with `sudo apt install xclip`),
58
+ `pbcopy` on macOS (built-in), `clip.exe` on Windows (built-in)
59
+
60
+ ## Security
61
+
62
+ Nothing is logged or stored. The tool processes data in memory only and does not
63
+ write any temporary files or make network requests.
64
+
65
+ ## License
66
+
67
+ MIT
@@ -0,0 +1,78 @@
1
+ Metadata-Version: 2.4
2
+ Name: b64-clip
3
+ Version: 1.0.0
4
+ Summary: Base64 encode/decode with clipboard, zero dependencies
5
+ Author: b64-clip contributors
6
+ License: MIT
7
+ Requires-Python: >=3.11
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Dynamic: license-file
11
+
12
+ # b64-clip
13
+
14
+ Base64 encode/decode with clipboard, zero dependencies.
15
+
16
+ Encode auth tokens, config values, certificate data, and more — result is
17
+ automatically copied to your clipboard.
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ pip install b64-clip
23
+ ```
24
+
25
+ Or run directly (no install):
26
+
27
+ ```bash
28
+ python3 b64_clip.py encode "hello world"
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ ```bash
34
+ # Encode a string
35
+ b64-clip encode "hello world"
36
+ # Output: aGVsbG8gd29ybGQ=
37
+ # (also copied to clipboard)
38
+
39
+ # Decode a string
40
+ b64-clip decode "aGVsbG8gd29ybGQ="
41
+ # Output: hello world
42
+ # (also copied to clipboard)
43
+
44
+ # Encode a file
45
+ b64-clip encode --file cert.pem
46
+
47
+ # Decode a file
48
+ b64-clip decode --file encoded.txt
49
+
50
+ # Pipe from stdin
51
+ echo "test" | b64-clip encode
52
+
53
+ # URL-safe base64 decode
54
+ b64-clip decode --url-safe "PDw_Pz4-"
55
+ ```
56
+
57
+ ## What it does
58
+
59
+ - **Encode**: Takes any input (string, file, or stdin) and outputs base64
60
+ - **Decode**: Takes base64 input and outputs the decoded plaintext
61
+ - **Clipboard**: Automatically copies the result to your clipboard on macOS,
62
+ Linux (xclip/wl-copy), and Windows (clip.exe)
63
+ - **Zero dependencies**: Python stdlib only — no pip install needed at runtime
64
+
65
+ ## Requirements
66
+
67
+ - Python 3.11+
68
+ - For clipboard support: `xclip` on Linux (install with `sudo apt install xclip`),
69
+ `pbcopy` on macOS (built-in), `clip.exe` on Windows (built-in)
70
+
71
+ ## Security
72
+
73
+ Nothing is logged or stored. The tool processes data in memory only and does not
74
+ write any temporary files or make network requests.
75
+
76
+ ## License
77
+
78
+ MIT
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ README.md
3
+ b64_clip.py
4
+ pyproject.toml
5
+ b64_clip.egg-info/PKG-INFO
6
+ b64_clip.egg-info/SOURCES.txt
7
+ b64_clip.egg-info/dependency_links.txt
8
+ b64_clip.egg-info/entry_points.txt
9
+ b64_clip.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ b64-clip = b64_clip:main
@@ -0,0 +1 @@
1
+ b64_clip
@@ -0,0 +1,123 @@
1
+ #!/usr/bin/env python3
2
+ """b64-clip — Base64 encode/decode with clipboard, zero dependencies."""
3
+
4
+ import argparse
5
+ import base64
6
+ import os
7
+ import platform
8
+ import subprocess
9
+ import sys
10
+
11
+
12
+ def copy_to_clipboard(text: str) -> bool:
13
+ """Copy text to clipboard. Returns True on success, False on failure."""
14
+ system = platform.system()
15
+ try:
16
+ if system == "Darwin":
17
+ proc = subprocess.run(["pbcopy"], input=text.encode(), check=True)
18
+ elif system == "Windows":
19
+ proc = subprocess.run(["clip.exe"], input=text.encode(), check=True)
20
+ else:
21
+ # Linux and other Unix — try xclip, then wl-copy (Wayland)
22
+ for cmd in (["xclip", "-selection", "clipboard"],
23
+ ["wl-copy"]):
24
+ try:
25
+ proc = subprocess.run(cmd, input=text.encode(), check=True)
26
+ break
27
+ except FileNotFoundError:
28
+ continue
29
+ else:
30
+ print("WARNING: No clipboard tool found (xclip or wl-copy). "
31
+ "Install xclip for clipboard support.", file=sys.stderr)
32
+ return False
33
+ return True
34
+ except (FileNotFoundError, subprocess.CalledProcessError) as e:
35
+ print(f"WARNING: Clipboard copy failed ({e}). "
36
+ "Output is still shown above.", file=sys.stderr)
37
+ return False
38
+
39
+
40
+ def read_input(args) -> bytes:
41
+ """Read input from --file, positional string, or stdin."""
42
+ if args.file:
43
+ fpath = os.path.expanduser(args.file)
44
+ if not os.path.isfile(fpath):
45
+ print(f"Error: File not found: {args.file}", file=sys.stderr)
46
+ sys.exit(1)
47
+ with open(fpath, "rb") as f:
48
+ return f.read()
49
+
50
+ if args.string:
51
+ return args.string.encode()
52
+
53
+ # Stdin pipe mode
54
+ if not sys.stdin.isatty():
55
+ return sys.stdin.buffer.read()
56
+
57
+ print("Error: No input provided. Pass a string argument, --file, or pipe data via stdin.",
58
+ file=sys.stderr)
59
+ sys.exit(1)
60
+
61
+
62
+ def encode(args):
63
+ """Base64-encode input and print + copy to clipboard."""
64
+ raw = read_input(args)
65
+ encoded = base64.b64encode(raw).decode()
66
+ print(encoded)
67
+ copy_to_clipboard(encoded)
68
+
69
+
70
+ def decode(args, url_safe: bool = False):
71
+ """Base64-decode input and print + copy to clipboard."""
72
+ raw = read_input(args).strip()
73
+ raw_str = raw.decode()
74
+
75
+ # Auto-detect URL-safe base64
76
+ if not url_safe and ("-" in raw_str or "_" in raw_str):
77
+ url_safe = True
78
+
79
+ try:
80
+ if url_safe:
81
+ # Add padding if missing
82
+ padding = 4 - len(raw_str) % 4
83
+ if padding != 4:
84
+ raw_str += "=" * padding
85
+ decoded = base64.urlsafe_b64decode(raw_str).decode()
86
+ else:
87
+ decoded = base64.b64decode(raw_str).decode()
88
+ except Exception as e:
89
+ print(f"Error: Decode failed ({e}). Check that input is valid base64.",
90
+ file=sys.stderr)
91
+ sys.exit(1)
92
+
93
+ print(decoded)
94
+ copy_to_clipboard(decoded)
95
+
96
+
97
+ def main():
98
+ parser = argparse.ArgumentParser(
99
+ prog="b64-clip",
100
+ description="Base64 encode/decode with clipboard, zero dependencies."
101
+ )
102
+ subparsers = parser.add_subparsers(dest="command", required=True)
103
+
104
+ # encode subcommand
105
+ enc = subparsers.add_parser("encode", help="Encode input to base64")
106
+ enc.add_argument("string", nargs="?", default=None, help="String to encode")
107
+ enc.add_argument("--file", "-f", default=None, help="File to encode")
108
+ enc.set_defaults(func=encode)
109
+
110
+ # decode subcommand
111
+ dec = subparsers.add_parser("decode", help="Decode base64 to plaintext")
112
+ dec.add_argument("string", nargs="?", default=None, help="Base64 string to decode")
113
+ dec.add_argument("--file", "-f", default=None, help="File containing base64 to decode")
114
+ dec.add_argument("--url-safe", action="store_true", default=False,
115
+ help="Use URL-safe base64 alphabet")
116
+ dec.set_defaults(func=lambda args: decode(args, url_safe=args.url_safe))
117
+
118
+ args = parser.parse_args()
119
+ args.func(args)
120
+
121
+
122
+ if __name__ == "__main__":
123
+ main()
@@ -0,0 +1,19 @@
1
+ [build-system]
2
+ requires = ["setuptools>=64", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "b64-clip"
7
+ version = "1.0.0"
8
+ description = "Base64 encode/decode with clipboard, zero dependencies"
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.11"
12
+ authors = [{name = "b64-clip contributors"}]
13
+ dependencies = []
14
+
15
+ [project.scripts]
16
+ b64-clip = "b64_clip:main"
17
+
18
+ [tool.setuptools]
19
+ py-modules = ["b64_clip"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+