2021.07.15 2024.07.05 2024.07.05 article Amenoum How to code a simple and fast crypter. computer science and engineering encryption, decryption, xor, crypter /authors/Amenoum.html#credits Tutorial on crypting Intro Generally, encryption is translation, or transformation, of content into a different language. When used to ensure secrecy, the product of encryption either has no meaningful interpretation or has low probability to be, without transformation, interpreted the same as the original content. However, in some cases of encryption, a transformation (decryption) algorithm can be constructed to reliably reproduce the original content. Encryption with low probability of original content restoration is generally lossy encryption and the product may be referred to as a hash of the original. Hashes are typically used in authorization to verify access credentials (eg. passwords), although, due to lossy encryption, a possibility always exists for different inputs to generate the same hash. The higher the entropy of hashes and the bigger the hash, the lower is the probability for such collisions. Lossy encryption can be interpreted as lossy compression of content if the interpretation of hash is similar to the original interpretation (eg. in lossy image compression, hash, or one segment of hash, may represent a superposition or average of two adjacent segments of the original, such as two adjacent pixels). Lossless encryption is lossless compression if the encrypted content is reduced in size compared to the original and if the original content can be reliably reproduced by some decryption algorithm. Any lossless compression is lossless encryption, although the products of lossless compression can have meaningful interpretation and may be interpreted the same as the original content. In other words, lossless encryption, when used as lossless compression, may not ensure secrecy.
To know the mechanics of a body of a universe is to master computer science, engineering and reverse engineering on that body. To understand its nature is to understand everything beyond the mechanic horizon. In its essence, understanding is decryption, and, generally, to understand a universe is to build a decryption algorithm without understanding the evolving language of evolving expression. Understanding between two living universes can only increase with shared evolution but can never be complete due to inherent inability to decrypt all the scales of its expression. Symbiosis, paradoxically, doesn't require increase in understanding, but ignorance of differences which then evolve compatibility to share space/time. With the increase in understanding of its self, that space/time will increase its distinct individuality, increasing introversion. Thus, in order for us to understand each other at all, it must be impossible for any one to completely understand its self. The choice of what to hide and when will depend on how we [want to] evolve.

Encryption today is very popular. However, most of encryption is not in control of the end user. This is a small tutorial, showing how to code a simple and fast crypter, as secure as one wants it to be. The code is thoroughly commented so it may also teach one basics of coding.
While encryption (hiding stuff) is common in polarized society, one may wonder whether it has its use in neutralum society. Perhaps this could be rephrased - does non-polarized nature use encryption, consciously? Relatively, nature does use encryption. There are hidden things and things we cannot decrypt, but that's reasonable. If everything would be revealed, it would be overwhelming and we couldn't exist (evolve), as per postulates of CR, absolute is equivalent to non-existing. But are hidden variables always non-consciously hidden? No, by polarized entities, they can, and at times will, be hidden consciously. I still like and want privacy, but perhaps that is only due to the fact I'm surrounded by polarized people - people who like to invade and exploit everything, including privacy, people who do not value what they do not understand and aim (often literally) to reduce it to something they can [believe to] understand. I believe privacy would be unnecessary between neutralums, but no society can be isolated, so something would be hidden to other species, even if not consciously.
Building encryption Here, an input file will be encrypted using nothing but the XOR operator between input bytes (bits) and the provided key (password). This makes the encryption trivial (it cannot get simpler than that) and fast. This also means the same program can be used to encrypt and decrypt files. To decrypt, one only needs to specify the encrypted file as input and output will be the original (decrypted) file, instead of the other way around. The strength of the encryption is proportional to the length of the key and its randomness. If the key is random enough and longer than input, and if the attacker does not know what to expect (and where) in the decrypted file, the encryption will be unbreakable.
For best security one shouldn't store the key anywhere, rather remember it. This may seem impossible because the key is also supposed to be random and long for best security. However, there is a way to use small and non-random phrases and still get practically unbreakable encryption. In example, one can use a key generator somewhere which would generate the key to be used in encryption from a short and memorable phrase specified. This key generator may simply apply some hash function (like md5) to the input multiple times to generate a very long key, but it is imperative here that the attacker does not suspect such key generator was used and, most importantly, that it does not know the algorithm behind it.
Code updated. The code The code below is written in PHP language. Why PHP? PHP has a C syntax, works the same on different platforms, it's simple and lightweight to install and use and can be used for both, web and desktop coding. It's what I use nowadays for all my backend coding. Some could say that's actually the real reason why I use it here as well...
The PHP code in a file starts with <?php tag and ends with a closing ?> tag (which may be omitted if it would be at the end of a file). Anything outside is not interpreted by PHP and will generally be printed to output - usually screen of a command line interface (CLI) or a browser (which will generally parse it as HTML code or plain text). Anything within /* and */ tags is considered a comment and is ignored by PHP parser. However, comments are often used to describe what the code does. The /* and */ are generally used for multi-line comments. For single line comments, it is more convenient to use //. Anything starting with // to the end of the line is then considered a comment. Note that, in PHP, variables must start with a dollar (\$) sign. Operators used in the code are described in Table 1.
operatorfunctiondescription
=assignmentassigns the value or result of an expression [on the right of the operator] to a variable specified on the left of the operator
!=comparison (tests for non-equality)returns true (boolean) if expression on the left evaluates to something different to expression on the right of the operator, false otherwise
==comparison (tests for equality)returns true if expression on the left evaluates to something equal to expression on the right of the operator, false otherwise
===comparison (tests for equality)the same as ==, except it also checks if data types are equal, eg. if there's 0 (integer) on the left and '0' (string) on the right, this will return false, whereas == would return true
&&logical ANDreturns true if both expressions (left and right) evaluate to true
||logical ORreturns true if at least one of the expressions (left or right) evaluate to true
.concatenationappends evaluated expression on the right to the left and returns the result (string)
.=assignment with concatenationappends evaluated expression on the right to the contents of a variable on the left, storing the result in the same variable
!logical negationevaluates expression on the right and returns its negation (inversion) - converts true to false and vice versa
^bitwise XORevaluates left and right expression and performs bitwise XOR operation between every bit, returning the result
Table 1: PHP operators used in code

Source code:

Article revised. Article revised.