Skip to content

Commit 2e05e22

Browse files
authored
start the package
1 parent 29f42cd commit 2e05e22

File tree

8 files changed

+340
-2
lines changed

8 files changed

+340
-2
lines changed

PDL/pdl/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from hash import keyPair, hash, hashFile, hashFileURL, compareHash
2+
from utility import filterFile, extractList, CC
3+
from colorum import text, background, style

PDL/pdl/colorum.py

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# Imports
2+
import sys, os
3+
from sys import platform
4+
5+
6+
# Global variables
7+
class colorCodes():
8+
black = str(0);
9+
blue = str(1);
10+
green = str(2);
11+
aqua = str(3);
12+
red = str(4);
13+
purple = str(5);
14+
yellow = str(6);
15+
white = str(7);
16+
grey = str(8);
17+
light_blue = str(9);
18+
light_green = str('A');
19+
light_aqua = str('B');
20+
light_red = str('C');
21+
light_purple = str('D');
22+
light_yellow = str('E');
23+
bright_white = str('F');
24+
25+
def ResetAll():
26+
os.system("Color " + colorCodes.black + colorCodes.white)
27+
return str("")
28+
29+
def clear():
30+
if platform == "linux" or platform == "linux2":
31+
os.system("clear")
32+
else:
33+
os.system("cls")
34+
return str("")
35+
36+
37+
class text():
38+
def Black():
39+
os.system("Color " + str(colorCodes.black))
40+
return str("")
41+
def Blue():
42+
os.system("Color " + str(colorCodes.blue))
43+
return str("")
44+
def Green():
45+
os.system("Color " + str(colorCodes.green))
46+
return str("")
47+
def Aqua():
48+
os.system("Color " + str(colorCodes.aqua))
49+
return str("")
50+
def Red():
51+
os.system("Color " + str(colorCodes.red))
52+
return str("")
53+
def Purple():
54+
os.system("Color " + str(colorCodes.purple))
55+
return str("")
56+
def Yellow():
57+
os.system("Color " + str(colorCodes.yellow))
58+
return str("")
59+
def White():
60+
os.system("Color " + str(colorCodes.white))
61+
return str("")
62+
def Grey():
63+
os.system("Color " + str(colorCodes.grey))
64+
return str("")
65+
def Lightblue():
66+
os.system("Color " + str(colorCodes.light_blue))
67+
return str("")
68+
def Lightgreen():
69+
os.system("Color " + str(colorCodes.light_green))
70+
return str("")
71+
def Lightaqua():
72+
os.system("Color " + str(colorCodes.light_aqua))
73+
return str("")
74+
def Lightred():
75+
os.system("Color " + str(colorCodes.light_red))
76+
return str("")
77+
def Lightpurple():
78+
os.system("Color " + str(colorCodes.light_purple))
79+
return str("")
80+
def Lightyellow():
81+
os.system("Color " + str(colorCodes.light_yellow))
82+
return str("")
83+
def Brightwhite():
84+
os.system("Color " + str(colorCodes.light_white))
85+
return str("")
86+
87+
def Reset():
88+
os.system("Color " + int(colorCodes.black))
89+
return str("")
90+
def clear():
91+
if platform == "linux" or platform == "linux2":
92+
os.system("clear")
93+
else:
94+
os.system("cls")
95+
return str("")
96+
97+
98+
class background():
99+
def Black():
100+
os.system("Color " + str(colorCodes.black + colorCodes.white))
101+
return str("")
102+
def Blue():
103+
os.system("Color " + str(colorCodes.blue + colorCodes.white))
104+
return str("")
105+
def Green():
106+
os.system("Color " + str(colorCodes.green + colorCodes.white))
107+
return str("")
108+
def Auqa():
109+
os.system("Color " + str(colorCodes.aqua + colorCodes.white))
110+
return str("")
111+
def Red():
112+
os.system("Color " + str(colorCodes.red + colorCodes.white))
113+
return str("")
114+
def Purple():
115+
os.system("Color " + str(colorCodes.purple + colorCodes.white))
116+
return str("")
117+
def Yellow():
118+
os.system("Color " + str(colorCodes.yellow + colorCodes.white))
119+
return str("")
120+
def White():
121+
os.system("Color " + str(colorCodes.white + colorCodes.black))
122+
return str("")
123+
def Grey():
124+
os.system("Color " + str(colorCodes.grey + colorCodes.black))
125+
return str("")
126+
def Lightblue():
127+
os.system("Color " + str(colorCodes.light_blue + colorCodes.white))
128+
return str("")
129+
def Lightgreen():
130+
os.system("Color " + str(colorCodes.light_green + colorCodes.white))
131+
return str("")
132+
def Lightaqua():
133+
os.system("Color " + str(colorCodes.light_aqua + colorCodes.white))
134+
return str("")
135+
def Lightred():
136+
os.system("Color " + str(colorCodes.light_red + colorCodes.white))
137+
return str("")
138+
def Lightpurple():
139+
os.system("Color " + str(colorCodes.light_purple + colorCodes.white))
140+
return str("")
141+
def Lightyellow():
142+
os.system("Color " + str(colorCodes.light_yellow + colorCodes.white))
143+
return str("")
144+
def Brightwhite():
145+
os.system("Color " + str(colorCodes.light_white + colorCodes.white))
146+
return str("")
147+
148+
def Reset():
149+
os.system("Color " + str(colorCodes.black))
150+
return str("")
151+
def clear():
152+
if platform == "linux" or platform == "linux2":
153+
os.system("clear")
154+
else:
155+
os.system("cls")
156+
return str("")
157+
158+
159+
class style():
160+
def Bright():
161+
os.system("Color " + str(colorCodes.bright_white))
162+
return str("")
163+
def Dim():
164+
os.system("Color " + str(colorCodes.grey))
165+
return str("")
166+
def ResetAll():
167+
os.system("Color " + str(colorCodes.black + colorCodes.white))
168+
return str("")
169+

PDL/pdl/hash.py

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import sys, os
2+
sys.path.append("c:/users/" + os.getlogin() + "/scoop/apps/python/current/lib/site-packages/dataextract")
3+
4+
try:
5+
import random
6+
import time
7+
import requests
8+
import hashlib
9+
import string
10+
except ImportError:
11+
print("Error: Missing module(s) please install the following module(s): random, time, hashlib, string")
12+
13+
14+
def keyPair(print=None):
15+
threshold = random.randint(2, 8)
16+
buff = random.randint(100, 10000)
17+
length = random.randint(50, 400)
18+
iterable = 0
19+
tiny = random.uniform(0.001, 0.999)
20+
alphabet = string.ascii_letters + string.digits
21+
publicBase = '.'.join(random.choice(alphabet) for i in range(buff))
22+
privateBase = '.'.join(random.choice(alphabet) for i in range(buff))
23+
24+
time.sleep(tiny)
25+
26+
publicList = publicBase.split('.')
27+
privateList = privateBase.split('.')
28+
29+
while iterable != threshold:
30+
x = privateList + publicList
31+
y = publicList + privateList
32+
for iteam in x, y:
33+
random.shuffle(x)
34+
random.shuffle(y)
35+
iterable += 1
36+
37+
time.sleep(tiny)
38+
39+
publicKey = ''.join(random.choice(x) for iterable in range(length))
40+
privateKey = ''.join(random.choice(y) for iterable in range(length))
41+
42+
if print is print:
43+
print(publicKey)
44+
print("")
45+
print(privateKey)
46+
else:
47+
return publicKey, privateKey
48+
49+
50+
def hash(target, print=None):
51+
sha256 = hashlib.sha256()
52+
xO = random.randint(10, 200)
53+
targetConvert = list(target)
54+
for i in range(xO):
55+
random.shuffle(targetConvert)
56+
57+
targetShuffled = ''.join(targetConvert)
58+
sha256.update(targetShuffled.encode())
59+
60+
if print != None:
61+
print(sha256.hexdigest())
62+
else:
63+
return sha256.hexdigest()
64+
65+
66+
def hashFile(file):
67+
BUF_SIZE = os.path.getsize(file)
68+
69+
sha256 = hashlib.sha256()
70+
71+
with open(file, 'rb') as f:
72+
while True:
73+
data = f.read(BUF_SIZE)
74+
75+
if not data:
76+
break
77+
sha256.update(data)
78+
79+
return sha256.hexdigest()
80+
81+
82+
def hashFileURL(url):
83+
newFile = str(f'C:/Users/{os.getlogin()}/Python-SafeGuard/newFile')
84+
with open (newFile, 'w') as f:
85+
f.write(requests.get(url).text)
86+
f.close()
87+
88+
BUF_SIZE = os.path.getsize(newFile)
89+
sha256 = hashlib.sha256()
90+
91+
with open(newFile, 'rb') as f:
92+
while True:
93+
data = f.read(BUF_SIZE)
94+
if not data:
95+
break
96+
sha256.update(data)
97+
98+
f.close()
99+
os.remove(newFile)
100+
return sha256.hexdigest()
101+
102+
103+
def compareHash(hashA, hashB):
104+
if hashA is hashB:
105+
return True
106+
else:
107+
return False

PDL/pdl/utility.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import os, sys
2+
import requests
3+
from sys import platform
4+
5+
def filterFile(file, blklistword):
6+
with open(file, "r+") as fin:
7+
content = fin.read()
8+
if content.find(blklistword) is True:
9+
writeIteam = content.replace(blklistword, "")
10+
fin.write(writeIteam)
11+
fin.close()
12+
else:
13+
pass
14+
15+
def extractList(file):
16+
with open(file, "r") as f:
17+
data = f.read()
18+
splitData = data.split('\n')
19+
f.close()
20+
21+
print(splitData)
22+
return splitData
23+
24+
def CC():
25+
if platform == "linux" or platform == "linux2":
26+
os.system("clear")
27+
else:
28+
os.system("cls")

PDL/setup.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# https://www.freecodecamp.org/news/build-your-first-python-package/
2+
from setuptools import setup, find_packages
3+
4+
VERSION = '1.2'
5+
DESCRIPTION = 'A package for cryptography in python with unique functions'
6+
LONG_DESCRIPTION = '''
7+
A python package for cryptography and data mixing from strings/files more on github.
8+
9+
https://github.com/itzCozi/HashBrowns-Python
10+
'''
11+
12+
# Setting up
13+
setup(
14+
name="hashbrowns",
15+
version=VERSION,
16+
author="Cooper ransom",
17+
author_email="Cooperransom08@outlook.com",
18+
description=DESCRIPTION,
19+
long_description=LONG_DESCRIPTION,
20+
packages=find_packages(),
21+
install_requires=[],
22+
23+
keywords=['python', 'crypto', 'cryptograpgy', 'rsa', 'hashing-algo'],
24+
classifiers= [
25+
"Development Status :: 3 - Alpha",
26+
"Intended Audience :: Education",
27+
"Programming Language :: Python :: 3",
28+
"Operating System :: Microsoft :: Windows",
29+
]
30+
)

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# New-Python-Package
2-
A liberay containng functions i made and use frequrently
1+
# Python-Developer-Library
2+
3+
This package contains all the functions i made and use frequently.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)