Skip to content

Commit

Permalink
0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Grosse-pasteque committed Jul 15, 2022
1 parent a090c4a commit 7525f93
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 30 deletions.
82 changes: 58 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Chr - EnD [0.4.0]
# Chr - EnD [0.5.0]

## By Grosse pastèque#6705
## By Big watermelon#6705

-------------

Expand All @@ -9,8 +9,8 @@

Python can transform letter to their index which is inside of the utf-8 table
```py
ord('a') -> 97
chr(97) -> 'a'
ord('a') -> 97
chr(97) -> 'a'
```

Simplified explainations:
Expand All @@ -19,48 +19,82 @@ Simplified explainations:
```py
text = list(text)

'hello' -> ['h', 'e', 'l', 'l', 'o']
"hello" -> ['h', 'e', 'l', 'l', 'o']
```

2) each char -> ord(char)
```py
ord('h') -> 104
```

3) return joined text
3) apply mathematical operations on the obtained number with modifiers
```py
104 -> 108 (+4)
```

4) return joined text
```py
'.'.join(text)

['104', '101', '108', '108', '111'] -> '104.101.108.108.111'
["108", "105", "112", "112", "116"] -> "108.105.112.112.116"
```

4) repeat 1, 2, 3 for number of required turns
5) repeat 1, 2, 3 and 4 for number of required turns


-------------


### Usage:
### Functions:

You have at your disposition two function:
- **ChrEnD.encrypt()**
- **ChrEnD.decrypt()**
You have at your disposition these function:
- **seed**
- **encrypt**
- **decrypt**
- **transform**
- **untransform**
- **combinations**

```py
import ChrEnD
import chrend

# all the allowed (operators, values): chrend.OPERATORS, chrend.CONV
seed = chrend.seed(turns=1, modifiers=[("+", "%l"), ("*", 2)])
print(seed)

encrypted = ChrEnD.encrypt('hello')
encrypted = ChrEnD.decrypt(encrypted)

print(encrypted)
print(decrypted)
encrypted = chrend.encrypt('hello ma boi :)', seed=seed)
print(repr(encrypted))

tencrypted = chrend.transform(encrypted)
print(repr(tencrypted))

encrypted = chrend.untransform(tencrypted)
print(repr(encrypted))

decrypted = chrend.decrypt(encrypted, seed=seed)
print(repr(decrypted))
```

##### Arguments
##### Seeds

Seeds works like in minecraft:

| argument | type | default (None = not default) | explainations |
| ------------ | ------------ | ------------ | ------------ |
| text | *str* | None | The text that you want to encrypt. |
| turns | *int* | 1 | Text will be encrypted in loop in range(turns). |
| modifier | *str* | 'self' | If you want to execute modification on the `ord(char)`, `self` corespond to the number, `word` to the original word. his modifier will be passed into `eval()`. |
| get_layers | *bool* | False | Return the encrypted/decrypted text and all the layers of the text. |
But be careful, modifiers are math operations so one modifier can be equal to another.
Example bellow

```py
import chrend

seed_one = chrend.seed(turns=1, modifiers=[("<<", 4)])
# 0x1a4b5

seed_two = chrend.seed(turns=3, modifiers=[("*", 16)])
# 0x1a16b2

encrypted_one = chrend.encrypt('text', seed=seed_one)
encrypted_two = chrend.encrypt('text', seed=seed_two)

print(encrypted_one == encrypted_two)
# shows: True
```
39 changes: 33 additions & 6 deletions example.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
import ChrEnD
from math import sqrt
import chrend

encrypted = ChrEnD.encrypt('hello')
decrypted = ChrEnD.decrypt(encrypted)

print(encrypted)
print(decrypted)
seed = chrend.seed(turns=1, modifiers=[("+", "%l"), ("*", 2)])
print(seed)


encrypted = chrend.encrypt('hello ma boi :)', seed=seed)
print(repr(encrypted))

tencrypted = chrend.transform(encrypted)
print(repr(tencrypted))

encrypted = chrend.untransform(tencrypted)
print(repr(encrypted))

decrypted = chrend.decrypt(encrypted, seed=seed)
print(repr(decrypted))


"""
If my math doesn't sucks:
should be better than SHA-256:
2 ** 256 VS 10027035 ** 12
should be better than SHA-512:
2 ** 256 VS 10027035 ** 23
"""
print('Beat SHA-256:', chrend.combinations(1, 12, 0x110000) > 2 ** 256)
print('Beat SHA-512:', chrend.combinations(1, 23, 0x110000) > 2 ** 512)

0 comments on commit 7525f93

Please sign in to comment.