diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 67a0e0a..b165ffe 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,7 @@ # Contributing to Cryptex 🤝 Firstly, thank you for taking the time to contribute.
-We welcome contributions from anyone willing to improve this project or add new features and you may see historic contributors on the repositories page on the right-hand panel. +We welcome contributions from anyone willing to improve this project or add new features. You may see historic contributors on the repositories page on the right-hand panel.
Contribution guidelines are listed below. Please take the time to go through the guidelines and follow them so that it is easy for maintainers to merge or address your contributions.
@@ -31,7 +31,7 @@ This project and everyone participating in it is governed by the [Cryptex Code o ## First time Contributor -As a first time contributor if you are not sure about contributing, feel free to ask our dev team on our [Discord Server](https://discord.gg/899KQFeAXr) +As a first-time contributor, if you are not sure about contributing, feel free to ask our dev team on our [Discord Server](https://discord.gg/899KQFeAXr)
A good place to start would be our list of [good first issues](https://github.com/SSGorg/Cryptex/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) @@ -42,25 +42,21 @@ A good place to start would be our list of [good first issues](https://github.co - Every change in this project must have an associated issue. **Issue before PR** ### Legal Notice -> When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project license. +> When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content, and that the content you contribute may be provided under the project license. To start contributing to this project, follow the steps below. ### Fork the Project -- Fork this repository. This will create a local copy of this repository on your github profile. +- Fork this repository. This will create a local copy of this repository on your GitHub profile. Fork Repository -- Now clone the forked repository on your local machine +- Now clone the forked repository on your local machine. ```bash git clone https://github.com//Cryptex.git ``` - For the [beta branch](https://github.com/SSGorg/Cryptex/tree/beta): - ```bash - git clone https://github.com//Cryptex.git -b beta - ``` - Keep a reference to the original project in `upstream` remote. @@ -76,12 +72,6 @@ To start contributing to this project, follow the steps below. git checkout -b main git rebase upstream/main ``` - For the [beta branch](https://github.com/SSGorg/Cryptex/tree/beta): - ```bash - git remote update - git checkout -b beta - git rebase upstream/beta - ``` ### Create a new branch @@ -97,7 +87,7 @@ git checkout -b branch_name - Work on the issue assigned to you. - Add all the files/folders needed. -- After you've made your contribution to the project add changes to the branch you've just created: +- After you've made your contribution to the project, add changes to the branch you've just created: ```bash # To add all new files to branch branch_name @@ -125,17 +115,16 @@ git push -u origin branch_name ### Pull Request -Go to your repository in the browser and click on compare and pull requests. +Go to your repository on your web browser and click on 'Compare and pull request'. This will send a request to the maintainer to add your contribution to the main repository `https://github.com/SSGorg/Cryptex`
Add a title to your Pull Request.
Make sure to mention which issue is solved with this Pull Request by mentioning the issue number #. Then add a description to your Pull Request that explains your contribution.
-#### **Note:** Make sure you are synched up to the [beta branch](https://github.com/SSGorg/Cryptex/tree/beta), and make your pull request merge into the [beta branch](https://github.com/SSGorg/Cryptex/tree/beta). ### Review -🎉🌟Congratulations! Sit and relax, you've made your contribution to Cryptex project. Wait until the PR is reviewed and incorporate changes suggested by the reviewers. After which the PR can be successfully merged. +🎉🌟Congratulations! Now sit and relax, you've made your contribution to the Cryptex project. Wait until the PR is reviewed and changes are incorporated as suggested by the reviewers, after which the PR can be successfully merged. ## Other Ways to Contribute diff --git a/README.md b/README.md index d25d1e9..278c3b4 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@

Locks only exist to keep honest people honest

+# V:1.0.0 Pumpkin Patch +

GitHub License GitHub Issues @@ -21,38 +23,39 @@ - [Our Amazing Contributors](#our-amazing-contributors) ## 📖 History -Cryptex started out in November 2021 with one developer Alex "cythes" Kollar as an attempt to be less of a script kiddy. -It has since became so much more. As of april 2022 Alex decided to open the project up to the SSG community to some absolutely incredible results. At this point the SSG | Cryptex Dev Team was founded with a the idea of building cryptex into a cryptography tool that people could use, install and add to with ease. Similar to metasploit. The project and team has evolved so much in just the little time it has existed. +Cryptex started out in November, 2021, with one developer, Alex "cythes" Kollar, as an attempt to be less of a script kiddie. +It has since then became so much more. As of April, 2022, Alex decided to open the project up to the SSG community to reap some absolutely incredible results. At this point, the SSG | Cryptex Dev Team was founded with a the idea of building Cryptex into a cryptography tool that people could use, install and add to with ease. Similar to Metasploit, the project and the team has evolved so much in the little time that it has existed for. -Cryptex itself maturing from Alex's seventeen original Hodge-podge of unoptimized tools, to what is now a professional grade cryptography toolkit. Cryptex is backed by a passionate team of devs ranging from beginners looking for a place to start to advanced devs who want a challenge. We even have a few idea men who come up with whacky encryption ideas for us to try to impliment. (Static Encryption. Go check it out.) Last but 110% not least our sponors who believe in the project enough to financially back us. +Cryptex itself has matured from Alex's hodgepodge of seventeen original but unoptimized tools, to what is now a professional-grade cryptography toolkit. Cryptex is backed by a passionate team of devs, ranging from beginners looking for a place to start, to advanced devs who want a challenge. We even have a few idea men who come up with wacky encryption ideas for us to try to implement. (Static Encryption; go check it out!) Lastly, but definitely not the least, this has been possible thanks to our sponsors who believe in the project enough to financially back us up. ## 🗓️ Upcoming Release ### Cryptex V1.0.0 - Pumpkin Patch 00 -After participation in Hacktoberfest 2022 we are going to put the collective updates from the event into a new realease. We are Dubbing the Pumpkin Patch. The plan is every year we do Hacktoberfest we will add a new Pumpkin Patch to Cryptex. + +After participation in Hacktoberfest 2022, we are going to put the collective updates from the event into a new release, which we will be dubbing as the Pumpkin Patch. The plan is that for every year we participate in Hacktoberfest, we will add a new Pumpkin Patch to Cryptex. Other notes: - We are moving away from the Earth Invader. -- complete rebuild of cryptex to work with Object Oriented Programming. -- Its now easier to implement new Ciphers and tools. -- Installer has been rewritten from the ground up in python. +- Complete rebuild of Cryptex to work with Object-Oriented Programming. +- It is now easier to implement new ciphers and tools. +- Installer has been rewritten from the ground-up in Python. - The main menu can now dynamically add ciphers and tools to the list. -- We brought back the OG 'Cryptex UI' (We made it look pretty again) -- Implimented a system that lets us use Ascii art for version names. +- We brought back the OG 'Cryptex UI' (we made it look pretty again). +- Implemented a system that lets us use ASCII art for version names. -All of this is pushing Cryptex ever closer to its goal of becoming the `metaploit of cryptography` +All of this is pushing Cryptex ever closer to its goal of becoming the `Metaploit of cryptography` ## [🛠️Basic Help](https://github.com/SSGorg/Cryptex/wiki/Cryptex-Syntax) ## 🖐️ Get in touch -### You can join in on chatting with the dev team on our discord server +### You can join in on chatting with the dev team on our Discord server Discord Server ## 🔧 Issues If you face any problems while using the application, please open an issue here ## 🤝 Contributing -Contributions, feedback, and bug reports are welcome! Feel free to check out our [issues page](https://github.com/SSGorg/Cryptex/issues) to find out what you could do! but before contrubuting make sure to check out [CONTRIBUTING.md](./CONTRIBUTING.md). -#### **NOTE:** All active development happens in the [beta branch](https://github.com/SSGorg/Cryptex/tree/beta) + +Contributions, feedback, and bug reports are welcome! Feel free to check out our [issues page](https://github.com/SSGorg/Cryptex/issues) to find out what you could do! But before contributing, make sure to check out [CONTRIBUTING.md](./CONTRIBUTING.md). ## Our Amazing Contributors🌟 diff --git a/requirements.txt b/requirements.txt index 7a40bd8..d69d454 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ qrcode Cryptography -googletrans==3.0.0 +googletrans==3.1.0a0 colorama pillow numpy diff --git a/src/cipher/cipher.py b/src/cipher/cipher.py index 09b5b71..e98afce 100644 --- a/src/cipher/cipher.py +++ b/src/cipher/cipher.py @@ -13,3 +13,7 @@ def print_options(): print(''' Not implemented. ''') + + def test(args): + raise Exception('Not implemented') + return {'status': False, 'msg': 'Not Implemented'} diff --git a/src/cipher/ciphers/L33T.py b/src/cipher/ciphers/L33T.py index edbd311..9d6f426 100644 --- a/src/cipher/ciphers/L33T.py +++ b/src/cipher/ciphers/L33T.py @@ -14,26 +14,16 @@ class L33T(Cipher): #make sure you change this from text to your cipher 'c': '(', 'e': '3', 'g': '6', - 'h': '#', - 'i': '¡', + 'h': 'H', + 'i': '1', 'k': 'X', - 'l': '1', + 'l': 'l', 'o': '0', 'p': '9', 's': '5', 't': '7', 'x': '*', 'z': '2', - '0': 'O', - '1': 'L', - '2': 'Z', - '3': 'E', - '4': 'A', - '5': 'S', - '6': 'G', - '7': 'T', - '8': 'B', - '9': 'P', } inverse_leet_speak = dict((v, k) for k,v in leet_speak.items()) @@ -76,3 +66,21 @@ def print_options(): python main.py l33t -e -t 'hello' python main.py l33t -d -t 'h3llo' ''') + + def test(args): + total = 2 + + args.text = 'hello' + expect = 'H3ll0' + out = L33T.encode(args) + if not out['success'] or out['text'] != expect: + return {'status': False, 'msg': f'''Failed to encode "{args.text}" + expected "{expect}" got "{out['text']}"'''} + + args.text, expect = expect, args.text + out = L33T.decode(args) + if not out['success'] or out['text'] != expect: + return {'status': False, 'msg': f'''Failed to decode "{args.text}" + expected "{expect}" got "{out['text']}"'''} + + return {'status': True, 'msg': f'Ran {total} tests'} diff --git a/src/cipher/ciphers/__init__.py b/src/cipher/ciphers/__init__.py index 132747a..9e807e9 100644 --- a/src/cipher/ciphers/__init__.py +++ b/src/cipher/ciphers/__init__.py @@ -22,3 +22,10 @@ from .ma import * from .bac import * from .ak import * +from .pf import * +from .affn import * +from .pb import * +from .sha224 import * +from .sha256 import * +from .sha384 import * +from .gc import * diff --git a/src/cipher/ciphers/affn.py b/src/cipher/ciphers/affn.py new file mode 100644 index 0000000..bf8014c --- /dev/null +++ b/src/cipher/ciphers/affn.py @@ -0,0 +1,101 @@ +""" +Author: Sparsh Gupta | Contributor +Description: Affine Cipher Implementation +""" +from cipher import Cipher +import math + +def extended_euclidean_common_devisor(a, b): + if a == 0: + return (b, 0, 1) + else: + gcd, x, y = extended_euclidean_common_devisor(b % a, a) + return (gcd, y - (b // a) * x, x) + + +def mod_inv(a, m): + gcd, x, _ = extended_euclidean_common_devisor(a, m) + if gcd != 1: + return None # modular inverse does not exist + else: + return x % m + +class Affine(Cipher): #make sure you change this from text to your cipher + + name = 'Affine' #change the name + type = 'cipher' + + + def encode(args): + text = args.text + key_a=args.key_a + key_b=args.key_b + + if not text: + return {'text': "No input text", 'success': False} + + if key_a==None : + key_a=1 + if key_b==None: + key_b=0 + + + default_dict='abcdefghijklmnopqrstuvwxyz' + m=len(default_dict) + + output='' + for char in text: + if(char in default_dict): + x=default_dict.find(char) + e_x=(key_a*x+key_b)%m + output+=default_dict[e_x] + else: + output+=char + return {'text': output, 'success': True} + + def decode(args): + text = args.text + key_a=args.key_a + key_b=args.key_b + + if not text: + return {'text': "No input text", 'success': False} + + if key_a==None : + key_a=1 + if key_b==None: + key_b=0 + + + default_dict='abcdefghijklmnopqrstuvwxyz' + m=len(default_dict) + + output='' + for char in text: + if(char in default_dict): + x=default_dict.find(char) + e_x=(mod_inv(key_a,m)*((x-key_b)%m))%m + output+=default_dict[e_x] + else: + output+=char + return {'text': output, 'success': True} + + + def print_options(): + #Edit this section as needed for your specific encoding / decoding. + print(''' + ### Modes + -d / --decode ---- decode + -e / --encode ---- encode + + ### Input + -t / --text ------ input text + -ka / --key_a ------input key -a + -kb / --key_b -------input key -b + + ### Examples + python main.py text -e -t 'hello' -ka 21 -kb 1 + python main.py text -d -t 'hello' -ka 2 + + Note: Cipher is Case Sensitive. Default Dictionary: abcdefghijklmnopqrstuvwxyz + ''') diff --git a/src/cipher/ciphers/b64.py b/src/cipher/ciphers/b64.py index a30f39d..f22e229 100644 --- a/src/cipher/ciphers/b64.py +++ b/src/cipher/ciphers/b64.py @@ -48,3 +48,21 @@ def print_options(): python main.py text -e -t 'hello' python main.py text -d -t 'hello' ''') + + def test(args): + total = 2 + + args.text = 'hello' + expect = 'aGVsbG8=' + out = B64.encode(args) + if not out['success'] or out['text'] != expect: + return {'status': False, 'msg': f'''Failed to encode {args.text} + expected "{args.text}" got "{out['text']}"'''} + + args.text, expect = expect, args.text + out = B64.decode(args) + if not out['success'] or out['text'] != expect: + return {'status': False, 'msg': f'''Failed to decode {args.text} + expected "{args.text}" got "{out['text']}"'''} + + return {'status': True, 'msg': f'Ran {total} tests'} diff --git a/src/cipher/ciphers/bin.py b/src/cipher/ciphers/bin.py index 898a42d..46e60cf 100644 --- a/src/cipher/ciphers/bin.py +++ b/src/cipher/ciphers/bin.py @@ -46,3 +46,23 @@ def print_options(): python main.py text -e -t 'hello' python main.py text -d -t 'hello' ''') + + def test(args): + total = 2 + + args.text = 'hello' + expect = '1101000 1100101 1101100 1101100 1101111' + # NOTE (marvhus): Should the binary output have a byte length of 7 or 8? + out = bin.encode(args) + if not out['success'] or out['text'] != expect: + return {'status': False, 'msg': f'''Failed to encode "{args.text}" + expected "{expect}" got "{out['text']}"'''} + + args.text, expect = expect, args.text + out = bin.decode(args) + if not out['success'] or out['text'] != expect: + return {'status': False, 'msg': f'''Failed to decode "{args.text}" + expected "{expect}" got "{out['text']}"'''} + + return {'status': True, 'msg': f'Ran {total} tests'} + diff --git a/src/cipher/ciphers/cc.py b/src/cipher/ciphers/cc.py index 8ac8797..c951f1a 100644 --- a/src/cipher/ciphers/cc.py +++ b/src/cipher/ciphers/cc.py @@ -66,3 +66,62 @@ def print_options(): python main.py cc -e -t "hello" -k 10 -ex '123456789' python main.py cc -d -t "hello" -k 10 -ex '123456789' ''') + + def test(args): + total = 0 + expect = [ + 'hello', + 'ifmmp', + 'jgnnq', + 'khoor', + 'lipps', + 'mjqqt', + 'nkrru', + 'olssv', + 'pmttw', + 'qnuux', + 'rovvy', + 'spwwz', + 'tqxxa', + 'uryyb', + 'vszzc', + 'wtaad', + 'xubbe', + 'yvccf', + 'zwddg', + 'axeeh', + 'byffi', + 'czggj', + 'dahhk', + 'ebiil', + 'fcjjm', + 'gdkkn', + 'hello', + ] + for i in range(1, 26): + total += 1 + args.text = 'hello' + args.key = i + out = CC.encode(args) + if not out['success']: + return {'status': False, 'msg': f''' + Encoding failed: "{out['text']}"'''} + + if out['text'] not in expect[i]: + return {'status': False, 'msg': f'''Failed to encode "hello" + expected "{expect[i]}" with key {i} got {out['text']}'''} + + for i in range(1, 26): + total += 1 + args.text = expect[i] + args.key = i + out = CC.decode(args) + if not out['success']: + return {'status': False, 'msg': f''' + Decoding failed: "{out['text']}"'''} + + if out['text'] not in 'hello': + return {'status': False, 'msg': f'''Failed to decode "{args.text}" + expected "hello" with key {i} got {out['text']}'''} + + return {'status': True, 'msg': f'Ran {total} tests'} diff --git a/src/cipher/ciphers/gc.py b/src/cipher/ciphers/gc.py new file mode 100644 index 0000000..c1f7566 --- /dev/null +++ b/src/cipher/ciphers/gc.py @@ -0,0 +1,80 @@ +from cipher import Cipher + + +class GC(Cipher): + + name = 'Gaderypoluki Cipher' + type = 'cipher' + + def code(args): + + text = args.text + + if not text: + return {'text': "No input text", 'success': False} + + encode_lower = { + 'g': 'a', + 'a': 'g', + 'd': 'e', + 'e': 'd', + 'r': 'y', + 'y': 'r', + 'p': 'o', + 'o': 'p', + 'l': 'u', + 'u': 'l', + 'k': 'i', + 'i': 'k', + } + encode_upper = { + 'G': 'A', + 'A': 'G', + 'D': 'E', + 'E': 'D', + 'R': 'Y', + 'Y': 'R', + 'P': 'O', + 'O': 'P', + 'L': 'U', + 'U': 'L', + 'K': 'I', + 'I': 'K', + } + + encode_text = '' + + for char in text: + if char.isupper(): + char = encode_upper.get(char, char) + encode_text += char + elif char.islower(): + char = encode_lower.get(char, char) + encode_text += char + else: + encode_text += char + + return {'text': encode_text, 'success': True} + + def encode(args): + output = GC.code(args) + return output + + def decode(args): + output = GC.code(args) + return output + + + def print_options(): + print(''' + ### Modes + -d / --decode ---- decode + -e / --encode ---- encode + + ### Input + -t / --text ------ input text + + ### Examples + python main.py gc -e -t 'hello' + python main.py gc -d -t 'hduup' + ''') diff --git a/src/cipher/ciphers/hex.py b/src/cipher/ciphers/hex.py index 23ff2ee..ae8c101 100644 --- a/src/cipher/ciphers/hex.py +++ b/src/cipher/ciphers/hex.py @@ -12,7 +12,6 @@ class Hex(Cipher): #make sure you change this from text to your cipher def encode(args): text = args.text - filename = args.output if not text: return {'text': "No input text", 'success': False} @@ -24,7 +23,6 @@ def encode(args): def decode(args): text = args.text - filename = args.output if not text: return {'text': "No input text", 'success': False} @@ -42,9 +40,28 @@ def print_options(): ### Input -t / --text ------ input text - -o / -output ----- output to file ### Example - python3 main.py -e -t 'Hello world!' -o ~/hello.txt + python3 main.py -e -t 'Hello world!' ''') #TODO(marvhus): Remove -o/--output and instead implement it in the Main.output() function + + def test(args): + total = 2 + + args.text = 'hello' + expect = '68656c6c6f' + out = Hex.encode(args) + if not out['success'] or out['text'] != expect: + return {'status': False, 'msg': f'''Failed to encode "{args.text}" + expected "{expect}" got "{out['text']}"'''} + + args.text = expect + expect = 'hello' + out = Hex.decode(args) + if not out['success'] or out['text'] != expect: + return {'status': False, 'msg': f'''Failed to decode "{args.text}" + expected "{expect}" got "{out['text']}"'''} + + return {'status': True, 'msg': f'Ran {total} tests'} + diff --git a/src/cipher/ciphers/mor.py b/src/cipher/ciphers/mor.py index 58349ee..161b9ca 100644 --- a/src/cipher/ciphers/mor.py +++ b/src/cipher/ciphers/mor.py @@ -123,3 +123,22 @@ def print_options(): python main.py mor -e -t 'hello' python main.py mor -d -t '.... . .-.. .-.. ---' ''') + + def test(args): + total = 2 + + args.text = 'HELLO' + expect = '.... . .-.. .-.. ---' + out = Mor.encode(args) + if not out['success'] or out['text'] != expect: + return {'status': False, 'msg': f'''Failed to encode "{args.text}" + expected "{expect}" got "{out['text']}"'''} + + args.text, expect = expect, args.text + out = Mor.decode(args) + if not out['success'] or out['text'] != expect: + return {'status': False, 'msg': f'''Failed to decode "{args.text}" + expected "{expect}" got "{out['text']}"'''} + + return {'status': True, 'msg': f'Ran {total} tests'} + diff --git a/src/cipher/ciphers/oct.py b/src/cipher/ciphers/oct.py index 3e36bc9..8a93e74 100644 --- a/src/cipher/ciphers/oct.py +++ b/src/cipher/ciphers/oct.py @@ -45,3 +45,21 @@ def print_options(): python main.py oct -e -t 'hello' python main.py oct -d -t '150 145 154 154 157' ''') + + def test(args): + total = 2 + + args.text = 'hello' + expect = '150 145 154 154 157' + out = Oct.encode(args) + if not out['success'] or out['text'] != expect: + return {'status': False, 'msg': f'''Failed to encode "{args.text}" + expected "{expect}" got "{out['text']}"'''} + + args.text, expect = expect, args.text + out = Oct.decode(args) + if not out['success'] or out['text'] != expect: + return {'status': False, 'msg': f'''Failed to decode "{args.text}" + expected "{expect}" got "{out['text']}"'''} + + return {'status': True, 'msg': f'Ran {total} tests'} diff --git a/src/cipher/ciphers/pb.py b/src/cipher/ciphers/pb.py new file mode 100644 index 0000000..92db0c9 --- /dev/null +++ b/src/cipher/ciphers/pb.py @@ -0,0 +1,51 @@ +from cipher import Cipher +import itertools + +class Pb(Cipher): + + name = 'Pb' + type = 'cipher' + + def brute(args): + text=args.text.strip() + range_split=[i.strip() for i in args.range.split(',') if i.strip()] + range_int=[int(i) for i in range_split if i.isdigit()] + step=1 + + # Validate if correct input + if not text: + return {'text': "No input text", 'success': False} + if not text.isdigit(): + return {'text': "Input Text should only contain digits", 'success': False} + + #Validate Range + if not range_int or len(range_int)!=len(range_split): + return {'text': "Improper Range", 'success': False} + + if len(range_int)<2: + range_int.append(range_int[0]+step) + + digits=[f"{i}" for i in range(10)] + + for length in range(range_int[0],range_int[1],step): + for item in itertools.product(digits, repeat=length): + guess = "".join(item) + if guess == text: + return {'text': "Found the pin", 'success': True} + + + return {'text': "Couldn't find the pin", 'success': True} + + def print_options(): + print(''' + ### Modes + -b / --brute ---- brute + ### Input + -t / --text ------ input text + -i / --input ------ input file [.txt] + -r / --range ------- range [, or ] + ### Examples + python main.py pb -b -t '1234' -r 4 + python main.py pb -b -t '1234' -r 3,5 + python main.py pb -b -i -r 2,3 + ''') \ No newline at end of file diff --git a/src/cipher/ciphers/pf.py b/src/cipher/ciphers/pf.py new file mode 100644 index 0000000..362431b --- /dev/null +++ b/src/cipher/ciphers/pf.py @@ -0,0 +1,168 @@ +from cipher import Cipher + +class PF(Cipher): + + name = 'Playfair' + type = 'cipher' + + def encode(args): + text = args.text + key=args.key + bogus='x' + ignore='i' + + if (not text.isalpha()): + return {'text': "Only alpha text accepted", 'success': False} + if (not key.isalpha()): + return {'text': "Key is not alphabetical", 'success': False} + + key=key.lower() + text=text.lower() + + # creation of 5x5 key matrix + key_mat=[ + ['','','','',''], + ['','','','',''], + ['','','','',''], + ['','','','',''], + ['','','','','']] + + alpha=[0]*26 + alpha[ord(ignore)-ord('a')]=1 + counter=0 + for ch in key: + if(alpha[ord(ch)-ord('a')]==0): + key_mat[counter//5][counter%5]=ch + alpha[ord(ch)-ord('a')]='1' + counter+=1 + + alpha_index=0 + while(alpha_index<26): + if(alpha[alpha_index]==0): + alpha[alpha_index]=1 + key_mat[counter//5][counter%5]=chr(ord('a')+alpha_index) + counter+=1 + alpha_index+=1 + + # Creates pairs from the input 'text' string + pairs=[] + index=0 + while (index argparse.Namespace: # Modes parser.add_argument("-e", "--encode", dest="encode", action="store_true", help="Encode mode") parser.add_argument("-d", "--decode", dest="decode", action="store_true", help="Decode mode") + parser.add_argument("--test", dest="test", action="store_true", help="Run all tests") + parser.add_argument("-b", "--brute", dest="brute", action="store_true", help="Brute mode") # Input parser.add_argument("-t", "--text", dest="text", type=str, help="The input text") @@ -110,6 +115,9 @@ def __run(self) -> argparse.Namespace: parser.add_argument("-src", dest="src_lang", type=str, help="source language") parser.add_argument("-dest", dest="dest_lang", type=str, help="destination language") parser.add_argument("-len", dest="length", type=int, help="length") + parser.add_argument("-ka", "--key_a", dest="key_a", type=int, help="Key -a") + parser.add_argument("-kb", "--key_b", dest="key_b", type=int, help="Key -b") + parser.add_argument("-r", "--range", dest="range", type=str, help="Range") args = parser.parse_args() @@ -141,6 +149,33 @@ def run(self): for layer in layers: args = self.parser.parse_string(layer) + if args.test: + print('\n') + status = [0, 0] + for k, v in self.cipher_list.items(): + try: + out = v.test(args) + except Exception as e: + print(f"{Fore.YELLOW}No test for {k}{Fore.WHITE}\n\t{e}") + else: + color = Fore.GREEN + msg = "Success:" + + if out['status']: + status[0] += 1 + else: + status[1] += 1 + color = Fore.RED + msg = "Failed: " + print(f"{color}{msg} {k} {'-' * (15 - len(k))} {out['msg']}{Fore.WHITE}") + + total = status[0] + status[1] + print(f"{Fore.GREEN}Success{Fore.WHITE}/{Fore.RED}Failed {Fore.WHITE}{status[0]}/{status[1]}") + percent = (status[0] / total) * 100 + print(f"Success percentage {percent}%") + + return + if not args.cipher: sys.exit("No cipher selected.") @@ -163,6 +198,8 @@ def run(self): func = module.encode elif args.decode: func = module.decode + elif args.brute: + func =module.brute else: print("No mode selected. see the help menu for more info") module.print_options() diff --git a/src/update.py b/src/update.py index 4b78baf..3048b4d 100644 --- a/src/update.py +++ b/src/update.py @@ -44,7 +44,8 @@ def compareVersions(self): return self.formatedOnlineVersion > self.formatedLocalVersion def getOnlineVersion(self): - url = f'https://raw.githubusercontent.com/SSGorg/Cryptex/{self.branch}/version' + user = 'SSGorg' + url = f'https://raw.githubusercontent.com/{user}/Cryptex/{self.branch}/version' response = requests.get(url) self.onlineVersion = response.text.split('\n')[0] @@ -53,9 +54,13 @@ def getFolder(): return os.path.abspath(os.path.dirname(__file__)) @staticmethod - def getLocalVersion(folder_path): + def getFullLocalVersion(folder_path): with open(folder_path + '/../version', 'rt') as f: - return f.read().split('\n')[0] + return f.read().split('\n') + + @staticmethod + def getLocalVersion(folder_path): + return Update.getFullLocalVersion(folder_path)[0] def parseVersion(self, versionString) -> str: formated = ''.join(versionString.split('.')) diff --git a/src/vars.py b/src/vars.py index 3673aaa..8e8315e 100644 --- a/src/vars.py +++ b/src/vars.py @@ -1,16 +1,21 @@ import update def banner(): - version = update.Update.getLocalVersion(update.Update.getFolder()) + localVersion = update.Update.getFullLocalVersion(update.Update.getFolder()) + + version = localVersion[0] spacing = len(version) - 5 - if spacing < 0: spacing = 0 - spacing = ' ' * spacing + spacing = ' ' * spacing if spacing > 0 else '' + + tag = f" {localVersion[1]}" + tag += f" - {localVersion[2]}" if len(localVersion) > 2 else "" + logo = [ f'{spacing} _____ __ ', f'{spacing} / ___/_____ _____ / /______ __', f'{spacing}/ /__/ __/ // / _ \\/ __/ -_) \\ /', f'{spacing}\\___/_/ \\_, / .__/\\__/\\__/_\\_\\ ', - f' V:{version}/___/_/ OOP Edition ', + f' V:{version}/___/_/{tag}', ' Locks only exist to keep honest', ' people honest ', ] diff --git a/version b/version index 8acdd82..45a8746 100644 --- a/version +++ b/version @@ -1 +1,2 @@ -0.0.1 +1.0.0 +Pumpkin Patch