storagepy 0.1.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.
- storagepy-0.1.0/LICENSE +21 -0
- storagepy-0.1.0/PKG-INFO +58 -0
- storagepy-0.1.0/README.md +45 -0
- storagepy-0.1.0/pyproject.toml +18 -0
- storagepy-0.1.0/setup.cfg +4 -0
- storagepy-0.1.0/storagepy/__init__.py +3 -0
- storagepy-0.1.0/storagepy/core.py +141 -0
- storagepy-0.1.0/storagepy.egg-info/PKG-INFO +58 -0
- storagepy-0.1.0/storagepy.egg-info/SOURCES.txt +10 -0
- storagepy-0.1.0/storagepy.egg-info/dependency_links.txt +1 -0
- storagepy-0.1.0/storagepy.egg-info/requires.txt +1 -0
- storagepy-0.1.0/storagepy.egg-info/top_level.txt +1 -0
storagepy-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Yuvaan Pandita and Nehan Nishad
|
|
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, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
storagepy-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: storagepy
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A simple text-based storage system where you can create tables, store data, and more! Encryption is included for data files.
|
|
5
|
+
Author: Yuvaan Pandita
|
|
6
|
+
Author-email: Nehan Nishad <creativenehan@gmail.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: cryptography
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# storagepy
|
|
15
|
+
|
|
16
|
+
storagepy is a lightweight text-based key-value storage system with strong AES encryption.
|
|
17
|
+
All functionality is contained in a single file: `core.py`.
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- Simple key-value text storage
|
|
22
|
+
- Automatic AES encryption key generation
|
|
23
|
+
- Strong encryption/decryption using Fernet (AES-128)
|
|
24
|
+
- Table formatting
|
|
25
|
+
- Key lookup
|
|
26
|
+
- Easy file creation
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
pip install storagepy
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
Create a file
|
|
33
|
+
from storagepy import create
|
|
34
|
+
|
|
35
|
+
# Create a new storage file
|
|
36
|
+
create("data.txt")
|
|
37
|
+
### Create a file
|
|
38
|
+
```python
|
|
39
|
+
from storagepy.core import createfile
|
|
40
|
+
createfile("data.txt")
|
|
41
|
+
### Upload data
|
|
42
|
+
from storagepy.core import upload
|
|
43
|
+
upload("data.txt", {"Name": "John", "Age": 15})
|
|
44
|
+
### Encrypt file
|
|
45
|
+
from storagepy.core import encrypt
|
|
46
|
+
encrypt("data.txt")
|
|
47
|
+
### Decrypt file
|
|
48
|
+
from storagepy.core import decrypt
|
|
49
|
+
decrypt("data.txt")
|
|
50
|
+
### Tablify (format)
|
|
51
|
+
from storagepy.core import tablify
|
|
52
|
+
print(tablify("data.txt"))
|
|
53
|
+
### Find data
|
|
54
|
+
from storagepy.core import find
|
|
55
|
+
print(find("Name", {"Name": "John", "Age": 15}))
|
|
56
|
+
###License
|
|
57
|
+
MIT
|
|
58
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# storagepy
|
|
2
|
+
|
|
3
|
+
storagepy is a lightweight text-based key-value storage system with strong AES encryption.
|
|
4
|
+
All functionality is contained in a single file: `core.py`.
|
|
5
|
+
|
|
6
|
+
## Features
|
|
7
|
+
|
|
8
|
+
- Simple key-value text storage
|
|
9
|
+
- Automatic AES encryption key generation
|
|
10
|
+
- Strong encryption/decryption using Fernet (AES-128)
|
|
11
|
+
- Table formatting
|
|
12
|
+
- Key lookup
|
|
13
|
+
- Easy file creation
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
pip install storagepy
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
Create a file
|
|
20
|
+
from storagepy import create
|
|
21
|
+
|
|
22
|
+
# Create a new storage file
|
|
23
|
+
create("data.txt")
|
|
24
|
+
### Create a file
|
|
25
|
+
```python
|
|
26
|
+
from storagepy.core import createfile
|
|
27
|
+
createfile("data.txt")
|
|
28
|
+
### Upload data
|
|
29
|
+
from storagepy.core import upload
|
|
30
|
+
upload("data.txt", {"Name": "John", "Age": 15})
|
|
31
|
+
### Encrypt file
|
|
32
|
+
from storagepy.core import encrypt
|
|
33
|
+
encrypt("data.txt")
|
|
34
|
+
### Decrypt file
|
|
35
|
+
from storagepy.core import decrypt
|
|
36
|
+
decrypt("data.txt")
|
|
37
|
+
### Tablify (format)
|
|
38
|
+
from storagepy.core import tablify
|
|
39
|
+
print(tablify("data.txt"))
|
|
40
|
+
### Find data
|
|
41
|
+
from storagepy.core import find
|
|
42
|
+
print(find("Name", {"Name": "John", "Age": 15}))
|
|
43
|
+
###License
|
|
44
|
+
MIT
|
|
45
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "storagepy"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "A simple text-based storage system where you can create tables, store data, and more! Encryption is included for data files."
|
|
5
|
+
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "Yuvaan Pandita" },
|
|
8
|
+
{ name = "Nehan Nishad", email = "creativenehan@gmail.com" }
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
readme = "README.md"
|
|
12
|
+
license = { text = "MIT" }
|
|
13
|
+
requires-python = ">=3.8"
|
|
14
|
+
|
|
15
|
+
dependencies = [
|
|
16
|
+
"cryptography",
|
|
17
|
+
]
|
|
18
|
+
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
def counter(counter):
|
|
2
|
+
try:
|
|
3
|
+
with open(counter,"r") as f:
|
|
4
|
+
p=f.read().split()
|
|
5
|
+
p=''.join(p)
|
|
6
|
+
with open(counter,"w") as f:
|
|
7
|
+
o = int(p) + 1
|
|
8
|
+
f.write(str(o))
|
|
9
|
+
return o
|
|
10
|
+
except FileNotFoundError:
|
|
11
|
+
with open(counter,"w") as f:
|
|
12
|
+
o=0
|
|
13
|
+
f.write(str(o))
|
|
14
|
+
return o
|
|
15
|
+
def upload(f,data):
|
|
16
|
+
items=[]
|
|
17
|
+
for key,value in data.items():
|
|
18
|
+
items.append("|-|")
|
|
19
|
+
items.append(key)
|
|
20
|
+
items.append("-->")
|
|
21
|
+
items.append(value)
|
|
22
|
+
with open(f,"w") as f:
|
|
23
|
+
for i in items:
|
|
24
|
+
f.write(str(i))
|
|
25
|
+
|
|
26
|
+
def read(file):
|
|
27
|
+
with open(file, "r") as f:
|
|
28
|
+
raw = f.read().strip()
|
|
29
|
+
|
|
30
|
+
entries = raw.split("|-|")
|
|
31
|
+
result = {}
|
|
32
|
+
|
|
33
|
+
for entry in entries:
|
|
34
|
+
if "-->" in entry:
|
|
35
|
+
key, value = entry.split("-->")
|
|
36
|
+
result[key] = value
|
|
37
|
+
|
|
38
|
+
return result
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def createfile(c):
|
|
44
|
+
name = f"dataset_{c}.txt"
|
|
45
|
+
with open(name, "w") as f:
|
|
46
|
+
pass
|
|
47
|
+
return name
|
|
48
|
+
|
|
49
|
+
def tablify(file):
|
|
50
|
+
with open(file, "r") as f:
|
|
51
|
+
raw = f.read().strip()
|
|
52
|
+
|
|
53
|
+
entries = raw.split("|-|")
|
|
54
|
+
result = {}
|
|
55
|
+
|
|
56
|
+
for entry in entries:
|
|
57
|
+
if "-->" in entry:
|
|
58
|
+
key, value = entry.split("-->")
|
|
59
|
+
result[key] = value
|
|
60
|
+
|
|
61
|
+
row_in = []
|
|
62
|
+
row_out = []
|
|
63
|
+
|
|
64
|
+
for key, value in result.items():
|
|
65
|
+
row_in.append(key)
|
|
66
|
+
row_out.append(value)
|
|
67
|
+
|
|
68
|
+
a = []
|
|
69
|
+
|
|
70
|
+
for i in row_in:
|
|
71
|
+
idx = row_in.index(i)
|
|
72
|
+
a.append(f"{i} | {row_out[idx]}")
|
|
73
|
+
colum_1=input("Name Colum 1: ")
|
|
74
|
+
colum_2=input("Name Colum 2: ")
|
|
75
|
+
import os
|
|
76
|
+
os.system("cls")
|
|
77
|
+
colums=f"""{colum_1} | {colum_2}"""
|
|
78
|
+
b=""""""
|
|
79
|
+
b=b+colums+"\n"+"-"*len(colums)+"\n"
|
|
80
|
+
for i in a:
|
|
81
|
+
b=b+i+"\n"
|
|
82
|
+
return b
|
|
83
|
+
def find(pair_key,data):
|
|
84
|
+
import os
|
|
85
|
+
counter=0
|
|
86
|
+
matches={}
|
|
87
|
+
keys=[]
|
|
88
|
+
for key,value in data.items():
|
|
89
|
+
if key.lower() == pair_key.lower():
|
|
90
|
+
counter+=1
|
|
91
|
+
matches[key]=value
|
|
92
|
+
keys.append(key)
|
|
93
|
+
if counter == 1:
|
|
94
|
+
print("Match Found!")
|
|
95
|
+
os.system("cls")
|
|
96
|
+
return matches
|
|
97
|
+
else:
|
|
98
|
+
print("No Match Found!")
|
|
99
|
+
os.system("cls")
|
|
100
|
+
return None
|
|
101
|
+
def encrypt(file):
|
|
102
|
+
with open(file, "r") as f:
|
|
103
|
+
raw = f.read().encode()
|
|
104
|
+
|
|
105
|
+
encrypted = FERNET.encrypt(raw)
|
|
106
|
+
|
|
107
|
+
with open(file, "wb") as f:
|
|
108
|
+
f.write(encrypted)
|
|
109
|
+
|
|
110
|
+
return encrypted
|
|
111
|
+
def decrypt(file):
|
|
112
|
+
with open(file, "rb") as f:
|
|
113
|
+
encrypted = f.read()
|
|
114
|
+
|
|
115
|
+
decrypted = FERNET.decrypt(encrypted)
|
|
116
|
+
|
|
117
|
+
with open(file, "w") as f:
|
|
118
|
+
f.write(decrypted.decode())
|
|
119
|
+
|
|
120
|
+
return decrypted.decode()
|
|
121
|
+
|
|
122
|
+
#===============================================
|
|
123
|
+
import os
|
|
124
|
+
from cryptography.fernet import Fernet
|
|
125
|
+
|
|
126
|
+
KEYFILE = "storagepy.key"
|
|
127
|
+
|
|
128
|
+
def load_or_create_key():
|
|
129
|
+
if not os.path.exists(KEYFILE):
|
|
130
|
+
key = Fernet.generate_key()
|
|
131
|
+
with open(KEYFILE, "wb") as f:
|
|
132
|
+
f.write(key)
|
|
133
|
+
return key
|
|
134
|
+
else:
|
|
135
|
+
with open(KEYFILE, "rb") as f:
|
|
136
|
+
return f.read()
|
|
137
|
+
|
|
138
|
+
# Auto-load key at module import
|
|
139
|
+
KEY = load_or_create_key()
|
|
140
|
+
FERNET = Fernet(KEY)
|
|
141
|
+
#===========================================================
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: storagepy
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A simple text-based storage system where you can create tables, store data, and more! Encryption is included for data files.
|
|
5
|
+
Author: Yuvaan Pandita
|
|
6
|
+
Author-email: Nehan Nishad <creativenehan@gmail.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: cryptography
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# storagepy
|
|
15
|
+
|
|
16
|
+
storagepy is a lightweight text-based key-value storage system with strong AES encryption.
|
|
17
|
+
All functionality is contained in a single file: `core.py`.
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- Simple key-value text storage
|
|
22
|
+
- Automatic AES encryption key generation
|
|
23
|
+
- Strong encryption/decryption using Fernet (AES-128)
|
|
24
|
+
- Table formatting
|
|
25
|
+
- Key lookup
|
|
26
|
+
- Easy file creation
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
pip install storagepy
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
Create a file
|
|
33
|
+
from storagepy import create
|
|
34
|
+
|
|
35
|
+
# Create a new storage file
|
|
36
|
+
create("data.txt")
|
|
37
|
+
### Create a file
|
|
38
|
+
```python
|
|
39
|
+
from storagepy.core import createfile
|
|
40
|
+
createfile("data.txt")
|
|
41
|
+
### Upload data
|
|
42
|
+
from storagepy.core import upload
|
|
43
|
+
upload("data.txt", {"Name": "John", "Age": 15})
|
|
44
|
+
### Encrypt file
|
|
45
|
+
from storagepy.core import encrypt
|
|
46
|
+
encrypt("data.txt")
|
|
47
|
+
### Decrypt file
|
|
48
|
+
from storagepy.core import decrypt
|
|
49
|
+
decrypt("data.txt")
|
|
50
|
+
### Tablify (format)
|
|
51
|
+
from storagepy.core import tablify
|
|
52
|
+
print(tablify("data.txt"))
|
|
53
|
+
### Find data
|
|
54
|
+
from storagepy.core import find
|
|
55
|
+
print(find("Name", {"Name": "John", "Age": 15}))
|
|
56
|
+
###License
|
|
57
|
+
MIT
|
|
58
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cryptography
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
storagepy
|