fcryptx 0.0.1__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.
fcryptx-0.0.1/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sreejith
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction...
fcryptx-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,41 @@
1
+ Metadata-Version: 2.4
2
+ Name: fcryptx
3
+ Version: 0.0.1
4
+ Summary: A lightweight AES encryption and decryption utility that can be used both as a command-line tool and as a Python package.
5
+ Author-email: Sreejith <sreejitharee123@gmail.com>
6
+ License: MIT
7
+ Project-URL: Repository, https://github.com/Sreejith-R-Mohan/fcryptx
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: cryptography==46.0.5
12
+ Dynamic: license-file
13
+
14
+ ### Project description
15
+
16
+ A lightweight AES encryption and decryption utility that can be used both as a command-line tool and as a Python package.
17
+
18
+ ## Prerequisites
19
+
20
+ **python >3.8** required*
21
+
22
+
23
+ ## To install
24
+ ```
25
+ pip install fcrypt
26
+ ```
27
+
28
+
29
+ ## Dependencies
30
+ cryptography:*46.0.5* ( Will install automatically )
31
+
32
+
33
+ ## Build Debian
34
+ ```
35
+ python setup.py --command-packages=stdeb.command bdist_deb
36
+ ```
37
+
38
+
39
+
40
+
41
+
@@ -0,0 +1,28 @@
1
+ ### Project description
2
+
3
+ A lightweight AES encryption and decryption utility that can be used both as a command-line tool and as a Python package.
4
+
5
+ ## Prerequisites
6
+
7
+ **python >3.8** required*
8
+
9
+
10
+ ## To install
11
+ ```
12
+ pip install fcrypt
13
+ ```
14
+
15
+
16
+ ## Dependencies
17
+ cryptography:*46.0.5* ( Will install automatically )
18
+
19
+
20
+ ## Build Debian
21
+ ```
22
+ python setup.py --command-packages=stdeb.command bdist_deb
23
+ ```
24
+
25
+
26
+
27
+
28
+
@@ -0,0 +1,51 @@
1
+ # Import statements
2
+ from cryptography.hazmat.primitives.ciphers.aead import AESGCM
3
+ from cryptography.hazmat.primitives.kdf.scrypt import Scrypt
4
+ import os
5
+
6
+
7
+ class Aes:
8
+ def __init__(self, key):
9
+ self.key = key
10
+
11
+
12
+ # Will generate key based on the master key
13
+ def convert_key_bits(self,salt: bytes,bit_len):
14
+ kdf = Scrypt(
15
+ salt=salt,
16
+ length=bit_len//8, # Generate key based on the bit size(128,192,256)
17
+ n=2**14,
18
+ r=8,
19
+ p=1
20
+ )
21
+ return kdf.derive(self.key.encode())
22
+
23
+
24
+
25
+ # encryption using salt + nonce
26
+ def encrypt(self, fdata, bit_len):
27
+ salt = os.urandom(16)
28
+ nonce = os.urandom(12)
29
+ key = self.convert_key_bits(salt, bit_len)
30
+
31
+ aesgcm = AESGCM(key)
32
+
33
+ data = fdata.encode()
34
+ # We are embedding salt + nonce in the string, so that it can be split during decryption
35
+ return salt+nonce+aesgcm.encrypt(nonce,data, None)
36
+
37
+
38
+
39
+
40
+ # decryption function
41
+ def decrypt(self, encrypted_text, bit_len):
42
+ # Spliting the bytes using slicing operator
43
+ salt = encrypted_text[:16]
44
+ nonce = encrypted_text[16:28]
45
+ enc_text = encrypted_text[28:]
46
+
47
+ key = self.convert_key_bits(salt, bit_len)
48
+
49
+ aesgcm = AESGCM(key)
50
+
51
+ return aesgcm.decrypt(nonce, enc_text, None)
File without changes
@@ -0,0 +1,132 @@
1
+ #! /usr/bin/python3
2
+
3
+ from .lib.Arguments import Arguments
4
+ from .algorithms.Aes import Aes
5
+ import sys
6
+ from pathlib import Path
7
+
8
+
9
+
10
+ class fcryptx:
11
+ def __init__(self,args: Arguments):
12
+ self.args = args
13
+
14
+ @classmethod
15
+ def cli_args(cls):
16
+ args = Arguments(sys.argv)
17
+ return cls(args)
18
+
19
+ @staticmethod
20
+ def help():
21
+ print("Usage: fcryptx [--e|--d] --algorithm=<algorithm> --key=<my_secretkey> --file=<path> [--out=<path>]")
22
+
23
+ def run(self):
24
+ arg = self.args
25
+
26
+
27
+ allowed_options = {'--e', '--d', '--algorithm', '--key', '--file', '--out'}
28
+
29
+ for raw in sys.argv[1:]:
30
+ option = raw.split('=')[0]
31
+ if option not in allowed_options:
32
+ fcryptx.help()
33
+ raise ValueError(f"Unknown argument: {option}")
34
+
35
+ if not arg.hasOption('--file'):
36
+ fcryptx.help()
37
+ raise ValueError("File name should not be empty")
38
+
39
+ file = Path(arg.getOptionValue('--file'))
40
+
41
+
42
+ if not file.exists():
43
+ raise FileNotFoundError("File does not exist")
44
+
45
+ if not arg.hasOption('--key'):
46
+ fcryptx.help()
47
+ raise ValueError("Enter the key value")
48
+
49
+ if not arg.hasOption('--algorithm'):
50
+ fcryptx.help()
51
+ raise ValueError("Enter a valid AES algorithm")
52
+
53
+
54
+ secret_key = arg.getOptionValue('--key')
55
+ algorithm = arg.getOptionValue('--algorithm')
56
+
57
+ bit_length = self._parse_algorithm(algorithm)
58
+
59
+ if arg.hasOption('--e') and arg.hasOption('--d'):
60
+ raise ValueError("Cannot use --e and --d together")
61
+
62
+ if (arg.hasOption('--e')):
63
+ # encryption
64
+ data = None
65
+ with open(file, 'r') as fp:
66
+ data = fp.read()
67
+
68
+ aes = Aes(secret_key)
69
+ encrypted_data = aes.encrypt(data,bit_length)
70
+
71
+ output_folder = arg.getOptionValue('--out') if arg.hasOption('--out') else '.'
72
+
73
+ output_path = Path(output_folder)
74
+ output_path.mkdir(parents=True, exist_ok=True)
75
+
76
+ # Create full output file path properly
77
+ output_file = output_path / (file.stem + '.enc')
78
+
79
+
80
+ with open(output_file,'wb') as fp:
81
+ fp.write(encrypted_data)
82
+ elif(arg.hasOption('--d')):
83
+ # decryption
84
+ data = None
85
+ with open(file, 'r') as fp:
86
+ data = fp.read()
87
+ aes = Aes(secret_key)
88
+ decrypted_data = aes.decrypt(data,bit_length)
89
+
90
+ output_folder = arg.getOptionValue('--out') if arg.hasOption('--out') else '.'
91
+
92
+ output_path = Path(output_folder)
93
+ output_path.mkdir(parents=True, exist_ok=True)
94
+
95
+ # Create full output file path properly
96
+ output_file = output_path / (file.stem + '.txt')
97
+
98
+
99
+ with open(output_file,'wb') as fp:
100
+ fp.write(decrypted_data)
101
+ else:
102
+ raise ValueError("Specify --e for encryption or --d for decryption")
103
+
104
+
105
+ def _parse_algorithm(self,algorithm):
106
+ try:
107
+ name, size = algorithm.split('-')
108
+ bit_length = int(size)
109
+ if name.lower() != "aes" or bit_length not in {128,192,256}:
110
+ raise ValueError
111
+
112
+ return bit_length
113
+
114
+ except ValueError:
115
+ raise ValueError("Algorithm must be AES-128, AES-192, or AES-256")
116
+
117
+
118
+
119
+ def main():
120
+ try:
121
+ if len(sys.argv) <= 3:
122
+ fcryptx.help()
123
+ sys.exit(1)
124
+
125
+ fcryptx.cli_args().run()
126
+
127
+ except Exception as e:
128
+ print(f"Error: {e}")
129
+ sys.exit(1)
130
+
131
+
132
+
@@ -0,0 +1,26 @@
1
+ class Arguments:
2
+ def __init__(self, args):
3
+ self.command = []
4
+ self.options = []
5
+ self.optionValues = {}
6
+ self.args = args
7
+
8
+ for arg in args:
9
+ if '-' in arg:
10
+ if '=' in arg:
11
+ split_options = arg.split("=")
12
+ self.optionValues[split_options[0]]=split_options[1]
13
+ self.options.append(split_options[0])
14
+ else:
15
+ self.options.append(arg)
16
+ else:
17
+ self.command.append(arg)
18
+
19
+
20
+ def hasOption(self,option):
21
+ return option in self.options
22
+
23
+ def getOptionValue(self,option):
24
+ return self.optionValues.get(option)
25
+
26
+
File without changes
@@ -0,0 +1,41 @@
1
+ Metadata-Version: 2.4
2
+ Name: fcryptx
3
+ Version: 0.0.1
4
+ Summary: A lightweight AES encryption and decryption utility that can be used both as a command-line tool and as a Python package.
5
+ Author-email: Sreejith <sreejitharee123@gmail.com>
6
+ License: MIT
7
+ Project-URL: Repository, https://github.com/Sreejith-R-Mohan/fcryptx
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: cryptography==46.0.5
12
+ Dynamic: license-file
13
+
14
+ ### Project description
15
+
16
+ A lightweight AES encryption and decryption utility that can be used both as a command-line tool and as a Python package.
17
+
18
+ ## Prerequisites
19
+
20
+ **python >3.8** required*
21
+
22
+
23
+ ## To install
24
+ ```
25
+ pip install fcrypt
26
+ ```
27
+
28
+
29
+ ## Dependencies
30
+ cryptography:*46.0.5* ( Will install automatically )
31
+
32
+
33
+ ## Build Debian
34
+ ```
35
+ python setup.py --command-packages=stdeb.command bdist_deb
36
+ ```
37
+
38
+
39
+
40
+
41
+
@@ -0,0 +1,16 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ requirements.txt
5
+ setup.py
6
+ fcryptx/fcryptx.py
7
+ fcryptx.egg-info/PKG-INFO
8
+ fcryptx.egg-info/SOURCES.txt
9
+ fcryptx.egg-info/dependency_links.txt
10
+ fcryptx.egg-info/entry_points.txt
11
+ fcryptx.egg-info/requires.txt
12
+ fcryptx.egg-info/top_level.txt
13
+ fcryptx/algorithms/Aes.py
14
+ fcryptx/algorithms/__init__.py
15
+ fcryptx/lib/Arguments.py
16
+ fcryptx/lib/__init__.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ fcrypt = fcryptx.fcryptx:main
@@ -0,0 +1 @@
1
+ cryptography==46.0.5
@@ -0,0 +1 @@
1
+ fcryptx
@@ -0,0 +1,28 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "fcryptx"
7
+ version = "0.0.1"
8
+ description = "A lightweight AES encryption and decryption utility that can be used both as a command-line tool and as a Python package."
9
+ authors=[
10
+ {'name'= 'Sreejith', email="sreejitharee123@gmail.com"}
11
+ ]
12
+ readme = "README.md"
13
+ requires-python = ">=3.8"
14
+ license = {text = "MIT"}
15
+ # 1. Tell setuptools that dependencies will be defined dynamically
16
+ dynamic = ["dependencies"]
17
+
18
+
19
+ # 2. Point to the requirements file
20
+ [tool.setuptools.dynamic]
21
+ dependencies = {file = ["requirements.txt"]}
22
+
23
+
24
+ [project.scripts]
25
+ fcrypt = "fcryptx.fcryptx:main"
26
+
27
+ [project.urls]
28
+ Repository = "https://github.com/Sreejith-R-Mohan/fcryptx"
@@ -0,0 +1 @@
1
+ cryptography==46.0.5
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
fcryptx-0.0.1/setup.py ADDED
@@ -0,0 +1,2 @@
1
+ from setuptools import setup
2
+ setup()