Skip to main content

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 but it depends.

Startup

First, make a logic gate file. The file extension should be .lgeso

Functions

Note, this README may sometimes be outdated due to how lazy and busy the dev is, for the most updated description of the function arguments please use “help({func})” and replace {func} with the function you want to check, thank you.

To use it, import LogicGate in your python script.

Remember for the decompile function, only the filename argument is needed.

The decompile function will return the incorrect bits if check, gate and ascii is True, decompiled result if ascii is True, and 0 if otherwise.

Outputs of the file will be printed(binary to ascii, and logical binary if enabled) if out is True (true by default).

The compile function does the otherwise, it normally doesn’t return anything but it can write code into lgeso file, or if write is False(default True) then the compiled result will be returned instead of writing into file.

Special encrypt module

a special encrypt module is included in this package, which is lgEncrypt.

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(). encrypt() have 4 arguments, data file name, key file name, message, output. They are very self explainatory

decrypt() have 5 arguments, data file, key file, sause, debug, debug_ALL. 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. For debug, it shows the print output that is hidden, it can be enabled for you to check which bit is wrong. For debug_ALL it purposely enable everything that is coded with printing(output) except warnings and errors, this will definatly cause massive lag so it is not recommended to enable.

syntax

For syntax it is very straight forward. It process each character in every line as individual command.

For gates with multiple inputs (such as or, and) type like other syntax, the quota for the gate will automatically be processed. invalid gate and missing input for gate will raise an error. In almost all scenarios, the case of the gate does not matter.

If the code on the same line have more than 1 final outputs, the first one will be used and the rest will be ignored

Basic gates:

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 is 1 special syntax

— (three hyphens): new word, used for the ascii output separating the binary for ascii translation. Everything else on the line with this syntax will be ignored.

### three hashes: comment, anything after this syntax will be ignored until a new line

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 more tham one special syntax appears in the same line, they will be scanned and processed with the priority according to here) (NOT USEFUL CURRENTLY)

examples (for version 1.2 -> 3.0)

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 seldom outdated wiki: LogicGate
Replit up-to-date version: replit

Roadmap

Version 1.2:
First release on PyPi
Version 1.3:
Introduced enhanced module lgEncrypt
Bug fix
Version 2.0:
Improved comment function
updated readme
updated code description
slight performance improve
Version 2.1:
Added tests
added functions output type recommendation
Version 2.5
Added ascii message detections on encryption/compilation functions
Slighly improved file extension detection
Version 2.6
improved file read system where all functions can be used while target file is already opened
improved formatting of the source code
Version 2.7
revamped source code comments, functions descriptions
overhauled readme
renamed function run to compile
kept the old run function and left a 3-version gap for all old programs to change the function name
Version 2.8
INFO LOST
Version 2.9
updated readme
added printing supression feature to all functions
provided 2 debug options for decrypt functon in lgEncrypt module
Version 3.0
Revamped the entire file read system, now rely on binary instead of texts (rejected)
Nothing changed
removed the old run function in LogicGate module
If nothing goes wrong, this project is now abandoned

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logicgate-0.3.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

logicgate-0.3.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file logicgate-0.3.0.tar.gz.

File metadata

  • Download URL: logicgate-0.3.0.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.10.8 Linux/6.2.0-1019-gcp

File hashes

Hashes for logicgate-0.3.0.tar.gz
Algorithm Hash digest
SHA256 c8cb8ed155c846701bbe0e7c03e96e09f2e9f4358f6f248961f9d44ba10044e6
MD5 38cfcd3d0c9585ed049aaf91cb7788f8
BLAKE2b-256 1634e0a8dd778a73fcc855f42cf545246eee1edc05168ced7a09fb5dba29ad1b

See more details on using hashes here.

File details

Details for the file logicgate-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: logicgate-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.10.8 Linux/6.2.0-1019-gcp

File hashes

Hashes for logicgate-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a8246dbe68cc1481a9d59879d6f51ac4c92494bee9dda52833f9e4987fd40afb
MD5 e08eb8c5b078a97e6718b3211d9cd943
BLAKE2b-256 ffaa0203eb9af9a82d4e945b7cbca62eb8561cbb797a76de753ffc2ecb4de1f5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page