Skip to content

Commit

Permalink
Merge pull request #11 from Windows-CPP/beta
Browse files Browse the repository at this point in the history
BugFix - Image Index Fix | v0.6.1-b | wint-stand
  • Loading branch information
Windows-CPP authored Nov 17, 2022
2 parents 4e12f55 + 45e56bd commit c54cedc
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 144 deletions.
69 changes: 0 additions & 69 deletions doc/readme.md

This file was deleted.

41 changes: 0 additions & 41 deletions functions.py

This file was deleted.

File renamed without changes
File renamed without changes
File renamed without changes
111 changes: 80 additions & 31 deletions lockbox_main.py
Original file line number Diff line number Diff line change
@@ -1,59 +1,83 @@
# LockBox | Windows NT Standalone Edition
# LockBox | Windows NT Standalone Build

# Imports
from random import randint, choice
from PIL import Image as imge
from functions import Encryptor # Will be used soon enough
# Windows NT Standalone Build
# v0.6-beta

# Temp Est Variables Variables
tempstr = ""
numFail = 0

# Coloured Text Variables
CEND = "\33[0m"
CRED = "\33[31m"
CORG = "\33[33m"
CBLU = "\33[34m"
CGRN = "\33[32m"

# Encryption & Decryption methods
def encrypt_dat(location, key):
"Encrypt the specified file"

def decrypt_dat(location, key):
"Decrypt the specefied file"


### MAIN ###
from pyth.settings import genInf
print("LockBox::Action::Starting")
print("LockBox::" + genInf["build"] + "/" + genInf["version"])

print("LockBox::Action::Boot::GetLibs()")

# Premade libs
from random import randint
from PIL import Image as imge # Image size reading lib

# Read from settings.json, and print collected imageLoc data to terminal
print("LockBox::Action::Starting::Reading//settings.jsonc")
print(CBLU + "LockBox::Action::Starting::ReadData//settings.jsonc: " + CEND)
from settings import imgLoc_1, imgLoc_2, imgLoc_3
setImp = (imgLoc_1 + " || " + imgLoc_2 + " || " + imgLoc_3)
# Custom libs & data
from pyth.settings import imgLoc # Image locations for later on
from pyth.functions import cls # will come in handy
from pyth.classes import EncDec # Main encryp/decryp class, kinda needed

################################################ BETA CHANNEL WORKLIST START ################################################
## Beta Worklist as of v0.6.0-b to v0.6.1-b, 16/11/2022 completed ##
# originally, this would inmport a set num of images
# now, it will import however many images are registered in `settings.py`
# makers life easier when 100+ imagse are imported for the final release

# Read from settings.py, and print collected imageLoc data to terminal
print("\n\nLockBox::Action::Starting::Reading//settings.py")
print(CBLU + "LockBox::Action::Starting::ReadData//settings.py: " + CEND)
setImp = ""
for i in range(len(imgLoc)):
setImp += str(imgLoc[i])
setImp += ", "

print(CGRN + str(setImp) + CEND)

# Creating a random number to choose an image
print("LockBox::Action::Starting::PixelRand//CreateNum()")
print("\nLockBox::Action::Starting::PixelRand//CreateNum()")
numList = []
for i in range(1000):
temp = randint(1, 3)
temp = randint(0, (len(imgLoc) - 1)) ## changed from 1 to 0, added -1, fixes bug outlined in bugReportLog_ID001.txt
numList.append(temp)

# Choosing random number to choose an image
print("\nLockBox::Action::Starting::PixelRand//CreateNum()")
print(CBLU + "LockBox::Action::Starting::PixelRand//NumList[]:" + CEND)
print(CGRN + str(numList) + CEND)
temp = randint(1, 1000)

temp = randint(0, len(imgLoc))
imgNum = numList[temp]
numList.clear()

# Opening image for use
print("\nLockBox::Action::Starting::ImageOpen() ")
for i in range(len(imgLoc)):
if(i == imgNum):
image = imge.open(imgLoc[imgNum])
elif(i != imgNum):
numFail += 1
else:
true = true

print(CORG + "LockBox::Action::Starting::PixelRand//FailCount: " + str(numFail) + CEND)
print(CGRN + "LockBox::Action::Starting::PixelRand//SuccessTry_Parse() " + CEND)

# Getting image pixel counts
print("LockBox::Action::Starting::PixelDet//PixelCount")
# opening images for use
if(imgNum == 1):
image = imge.open(imgLoc_1)
elif(imgNum == 2):
image = imge.open(imgLoc_2)
elif(imgNum == 3):
image = imge.open(imgLoc_3)
print("\nLockBox::Action::Starting::PixelDet//PixelCount")

width, height = image.size

Expand All @@ -71,15 +95,40 @@ def decrypt_dat(location, key):

print(CGRN + str(colourSTR) + CEND)

print("LockBox::Action::Starting::PixelFinal//FinalList")

################################################ BETA CHANNEL WORKLIST END ################################################


# Created the final numbers for use in the keygen
print("\nLockBox::Action::Starting::PixelFinal//FinalList")
finalList = ""
for i in range(256):
temp = randint(1, (len(colourSTR) - 1))
char = colourSTR[temp]
finalList += char

# Generates a 4-digit ferpin at the end of encryption
print(CBLU + "LockBox::Action::Starting::PixelFinal//FET_Pin:" + CEND)
for i in range(4):
temp = randint(1, 256)
temp = randint(0, 255)
tempstr += finalList[temp]
print(CGRN + tempstr + CEND)
print(CGRN + tempstr + CEND)

"""
Note for future reference
The string `finalList` contains the 256 numbers that should be used from now out, disregard most of the other lists and variables-
they're safe to overwrite now
"""

# Possible way to do 256x encryption-
# Index # of charachters in document
# Take current indexed charachter and find it's char value
# Add number if <= 6, subtract number if >=5
# Add charachter to spot
# Repeat for every number in FinalList until original charachter is 256 different charachters

# For decryption-
# Group the document into 256-byte sized chunks (256 characters per chunk)
# Use the opposite method of encryption- add number if >=, subtract if <= 6
# If all 256 characters are the same, then replace all of them with just one of that character
# Else, there is document corruption
18 changes: 18 additions & 0 deletions pyth/classes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class EncDec():
'Class that houses the main Encryption and Decryption methods for LockBox. Usage: `EncDec.crypt(key, location)`, `EncDecName.decrypt(key, location)`'

def __init__(self, keyIn, locIn):
'Init class for EncDec.'
self.__key__ = keyIn
self.__location__ = locIn

def updateDat(self, keyIn, locIn):
'Updates location and key for EncDec.'
self.__key__ = keyIn
self.__location__ = locIn

def crypt(self, __key__):
'The main encryption algorithym for LockBox.'

def decrypt(self, __key__):
'The main decryption algorithym for LockBox.'
5 changes: 5 additions & 0 deletions pyth/functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from os import system

def cls():
'Clears the CLI.'
system("cls")
10 changes: 10 additions & 0 deletions pyth/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
imgLoc = {
0:"./images/1.jpg",
1:"./images/2.jpg",
2:"./images/3.jpg"
}

genInf = {
"build":"wint-standalone",
"version":"v0.6.1-b"
}
16 changes: 16 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# LockBox - A Personal Server Security Solution

## Design

### What it Does

LockBox is an encryption method that is designed to run standalone or as a method inside of another Python program.
It takes a string-based input (Input *can* be an `int`, but will return as an `str`).
This is taken through our encryption algorithim to try and make data secure in a 256-bit format.

### How it Works

LockBox first generates random numebrs as best as it can, several times over again to find a true random number.
It then looks at pixels of an image, and finds random pixels out of a random image out of a random selection of images- Really, really random.
Using these found pixels, it takes their RGB values and generates a key out of those colour values, as well as more random numbers.
Through this key, it encrypts your data into a long and secure string, only decryptable via the same key.
3 changes: 0 additions & 3 deletions settings.py

This file was deleted.

0 comments on commit c54cedc

Please sign in to comment.