an esolang designed for manual encryption with logic gates
Project description
LogicGate
This language is inspired by logic gates, by using simple alphabet you could make a program.
It is designed as a way for manual encryption, which kinda failed
All you can do in this language is to make a program with logic gates, sounds difficult and indeed it is.
Startup
First, make a logic gate file. The file extension should be lgeso
Runner
To use it, import the python file LogicGate.py in your python script, or just run the LogicGate.py. Remember for the run function, only the filename argument is needed. The run function will return an exit code if you use the run function, and outputs of the file will be printed(binary to ascii, and logical binary if enabled). The compile function does the otherwise, it doesn’t return anything but it can write code into lgeso file.
Special encrypt module
a special encrypt module is included in this package, which is lgEncrypt.py. it contain two functions, encrypt() and decrypt(). encrypt() generates a key file and a data file, they are pure random string when transfered to ascii, but shows message when both being processed by decrypt() encrypth) have 3 arguments, data file name, key file name, message They are very self explainatory
decrypt() have 3 arguments, data file, key file, sause the first 2 is very self explainatory, for sause parameter it determinates if the output text is shown or returned for further decryption, assuming the message through encrypt() is encrypted beforehand
syntax
For syntax it is very straight forward. It process each character in each line as each command For gates with multiple inputs (such as or, and) type like other syntax, the quota for the gate will automatically be processed. No linking between words, unless the syntax at the middle is invalid
Basic gates(gates that doesn’t require includes):
A (and gate): the next 2 results will be accepted as inputs. If both inputs are 1, output is 1, else 0
O (or gate): the next 2 results will be accepted as inputs. If one of the inputs are 1, output is 1, else 0
N (not gate): the next 1 result will be accepted as inputs. If the input is 1, output is 0, else 0
1 and 0 (True and False): NO result will be accepted as inputs. They are the results, self explanatory
special syntax
There are 2 special syntax
—– (three hyphens): new word, used for the ascii output separating the binary for ascii translation
### (three hashes): comment everything after the syntax
For any of the special syntax, they are not being interpreted as special syntax unless the entire syntax appears. They can be anywhere in a line, and that line will act like what the syntax shows (if the special syntax appears in the same line, they will be scanned and processed according to here)
examples
This is a hello world in LogicGate
1\n 0\n 0\n 1\n 0\n 0\n 0\n ---\n 1\n 1\n 0\n 0\n 1\n 0\n 1\n ---\n 1\n 1\n 0\n 1\n 1\n 0\n 0\n ---\n 1\n 1\n 0\n 1\n 1\n 0\n 0\n ---\n 1\n 1\n 0\n 1\n 1\n 1\n 1\n ---\n 1\n 0\n 0\n 0\n 0\n 0\n ---\n 1\n 0\n 1\n 0\n 1\n 1\n 1\n ---\n 1\n 1\n 0\n 1\n 1\n 1\n 1\n ---\n 1\n 1\n 1\n 0\n 0\n 1\n 0\n ---\n 1\n 1\n 0\n 1\n 1\n 0\n 0\n ---\n 1\n 1\n 0\n 0\n 1\n 0\n 0\n ---\n 1\n 0\n 0\n 0\n 0\n 1\n
another version generated by LogicGate.compile(): O1NNAANNNNA1AA1AO0AA1AO1NNANNAA1A1111111111\n NNANNAAAO0O000001\n OO0NNN10\n O1O1NNA1O01\n NNOONNA0O0000\n 0\n AA0NNANNOONNNNAO0A1O0000001\n ---\n OO1O1OAO1NNAO111111\n NNNNO0NNAA1O0N01\n OANNOA0O00000\n ANNNNA001\n NNA11\n NNANNA1ANNO0001\n NNAANNAOOA1NNAO10110111\n ---\n OA111\n A1OA1OO0A1O1NNA1O0ONNNNNNN0000\n A1O0A00\n A1O0NNAO0O0A111\n NNAO1NNONNNNA1O1111\n O0A1OANNA0NNOO0ON10000\n 0\n ---\n O0NNN0\n A1ANNNNNNNNNNO101\n O00\n NNA1OO1ONNAO10110\n OAA1110\n OO0AAO0AAONNO0O0NNO00001100\n NNO0A0ONNN10\n ---\n O0O1O0A1NNO1ANNO0AA1O1AA1A1A11111\n NNANNO1ONNNNNNNNNNO0AO11101\n O0OONNNNAAO0N11000\n A1O0N0\n OONNNNOA1ONNOO0AA11100100\n NNO0ON00\n O0OA1NNA1O100\n ---\n O0OO1OO1A1O1000\n NNOO0AONNONNO0A0NNA0NNA010010\n NNAA0OOOA0O000001\n A0NNNNN1\n AO0NNNNA1OO0001\n O0OA1O0O0OO0OA1O00000\n ---\n 1\n A0NNAO0A0OA0NNA1A0000\n NNO0NNA1NNOO011\n NNO0NNA0A0A0NNOO000\n ANNA1AA1NNNNNNNNAA1NNAA1A111111\n NNA1ANNA1OAO1O11111\n A1A1NNA1O1NNANNA1AA1111\n ---\n ONNNNAOO11110\n OANNOONNA1AA1110111\n AA0NNNNNNO0O0A0O0N10\n NNNNNNOA110\n O1OONNA1101\n A1NNNNA11\n ANNOONNAAO1A1ANNA11111011\n ---\n O0NNO0AO0A111\n NNNNNNA1O0ONNA1NNNNO0NNANNOOA1ANNNNAA11110111\n NNO11\n AO0AN101\n OAA1000\n 1\n O0A0NNO0O0NNA0A0NNA1ON10\n ---\n O0N0\n NNNNNNO0ONNA1N00\n O00\n O0AN01\n NNONNNNNNNNA111\n NNNNONNOO0000\n AONNO0ANNO00101\n ---\n O1ONNANNNNA1111\n NNNNOOOO0NNAA1NNONNO1011111\n NNA0A0A01\n AA1N10\n O1OANNNNNNA1ONNNNOO1AOOO1AAN0110111110\n 0\n OOAO0NNO0A0OAANNA0AONNO0001100000\n ---\n A1A1NNO0NNA11\n OA100\n NNANNOA1001\n 0\n NNO0OA0O000\n ANNO0OONNA1O11001\n ---
Sources
Esolang wiki: LogicGate
Replit up-to-date version: replit
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for LogicGate-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f301faae7f714399d5d2cc07dec8d0367558c3fa9665587624647c630e8f964f |
|
MD5 | 75f45009763b7532effdf855916e8c15 |
|
BLAKE2b-256 | 8f1235dc03828be807e89f17b160942f5b0463681b412e84cf64f9ffe5371258 |