ensec-cli 1.0.6__tar.gz → 1.0.8__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.
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ensec-cli
3
- Version: 1.0.6
3
+ Version: 1.0.8
4
4
  Summary: EncryptSecureDEC Open Source CLI
5
- Requires-Python: >=3.8
5
+ Requires-Python: >=3.9
6
6
  Description-Content-Type: text/markdown
7
7
  License-File: LICENSE
8
8
  Requires-Dist: pycryptodome
@@ -0,0 +1 @@
1
+ __version__ = "1.0.8"
@@ -252,6 +252,30 @@ def cli_verify_chain(file_path):
252
252
  rsa_encryptor.ensure_rsa_keys()
253
253
  from .utils import decrypt_folder_cli,encrypt_folder
254
254
 
255
+ def password_from_keyfile(keyfile_path: str) -> str:
256
+ """
257
+ キーファイルの内容からパスワード相当の文字列を生成する。
258
+ ファイル内容が1bitでも変わると復号できなくなる。
259
+ """
260
+ path = Path(keyfile_path)
261
+
262
+ if not path.is_file():
263
+ print(f"❌ Error: Key file not found - {keyfile_path}")
264
+ sys.exit(1)
265
+
266
+ try:
267
+ with open(path, "rb") as f:
268
+ data = f.read()
269
+ except Exception as e:
270
+ print(f"❌ Error: Failed to read key file - {e}")
271
+ sys.exit(1)
272
+
273
+ if not data:
274
+ print("❌ Error: Key file is empty.")
275
+ sys.exit(1)
276
+
277
+ return hashlib.sha256(data).hexdigest()
278
+
255
279
  def main():
256
280
  parser = argparse.ArgumentParser(description="EncryptSecureDEC CLI")
257
281
  parser.add_argument("mode",choices=["encrypt","decrypt","verify-chain","sign",
@@ -263,6 +287,7 @@ def main():
263
287
  parser.add_argument("--rsa", action="store_true",help="Encrypt / Decrypt RSA Mode")
264
288
  parser.add_argument("--dir", action="store_true",help="Encrypt Dir mode")
265
289
  parser.add_argument("--pubkey", help="Path to public key file (only required in RSA encrypt mode)")
290
+ parser.add_argument("--keyfile",help="Use a file as the password source for encryption/decryption")
266
291
  args = parser.parse_args()
267
292
 
268
293
  # --- validate RSA/pubkey usage ---
@@ -287,7 +312,13 @@ def main():
287
312
  sys.exit(result)
288
313
 
289
314
  if not args.rsa and ext != ".rdec" and args.mode != "sign" and args.mode != "verify-sign" and args.dir!=True and ext!=".esdc":
290
- password = args.password or getpass.getpass("🔑 Enter password: ")
315
+ if args.keyfile and args.password:
316
+ print("❌ Error: --password and --keyfile cannot be used together.")
317
+ sys.exit(1)
318
+ if args.keyfile:
319
+ password = password_from_keyfile(args.keyfile)
320
+ else:
321
+ password = args.password or getpass.getpass("🔑 Enter password: ")
291
322
 
292
323
  # Check if file exists
293
324
  if not os.path.isfile(args.file) and args.dir!=True:
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ensec-cli
3
- Version: 1.0.6
3
+ Version: 1.0.8
4
4
  Summary: EncryptSecureDEC Open Source CLI
5
- Requires-Python: >=3.8
5
+ Requires-Python: >=3.9
6
6
  Description-Content-Type: text/markdown
7
7
  License-File: LICENSE
8
8
  Requires-Dist: pycryptodome
@@ -4,9 +4,9 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ensec-cli"
7
- version = "1.0.6"
7
+ version = "1.0.8"
8
8
  description = "EncryptSecureDEC Open Source CLI"
9
- requires-python = ">=3.8"
9
+ requires-python = ">=3.9"
10
10
  readme = "README.md"
11
11
 
12
12
  dependencies = [
@@ -1 +0,0 @@
1
- __version__ = "1.0.6"
File without changes
File without changes
File without changes
File without changes