Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a14c2de

Browse files
Adding Caesar Cipher
1 parent 7620f3a commit a14c2de

File tree

1 file changed

+45
-2
lines changed
  • Advanced Application/API-Obfuscator

1 file changed

+45
-2
lines changed

β€ŽAdvanced Application/API-Obfuscator/main.pyβ€Ž

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import pathlib
33
import os
44
import re
5+
import string
56
from pathlib import Path
67

78

@@ -16,12 +17,32 @@ def relative_to_assets(path: str) -> Path:
1617
return API_PATH / Path(path)
1718

1819

20+
shiftAlpha = 4
1921
API_CONTENT = None
2022
# πŸ” Security execution READ
2123

2224

2325
def API_SEC():
2426
global API_CONTENT
27+
global shiftAlpha
28+
29+
# Caesar Cipher
30+
alphaCharset = string.ascii_letters
31+
numCharset = string.digits
32+
charsetMain = alphaCharset + numCharset
33+
34+
totalNum = 0
35+
for i in range(len(charsetMain)):
36+
totalNum += i
37+
38+
shiftAlpha %= totalNum
39+
40+
unshiftAlpha = -shiftAlpha
41+
42+
alphaUnshifted = None
43+
alphaUnshifted = charsetMain[unshiftAlpha:] + charsetMain[:unshiftAlpha]
44+
tableContentUn = str.maketrans(charsetMain, alphaUnshifted)
45+
2546
# Security measures
2647
API_CONTENT = open(relative_to_assets("Data/security/API"), "r").read()
2748
API_DECODED = base64.b64decode(API_CONTENT.encode("utf-8"))
@@ -30,14 +51,36 @@ def API_SEC():
3051
API_DECODED_CLEAN = re.sub(
3152
r"[^A-Za-z0-9-]", "", API_DECODED.decode("utf-8"))
3253

33-
return API_DECODED_CLEAN
54+
UNLOCKED_CONTENT = str(API_DECODED_CLEAN).translate(tableContentUn)
55+
56+
return UNLOCKED_CONTENT
3457

3558

3659
print("\nAdd your API here.\nNEVER CHANGE THE API KEY DIRECTLY\nFOR SECURITY REASONS!\n")
3760
userChange = input("Enter API key: ").strip()
3861

62+
# Caesar Cipher
63+
alphaCharset = string.ascii_letters
64+
numCharset = string.digits
65+
# Combine both alphaCharset with numCharset in one variable
66+
charsetMain = alphaCharset + numCharset
67+
68+
totalNum = 0
69+
for i in range(len(charsetMain)):
70+
totalNum += i
71+
72+
# print(totalNum)
73+
shiftAlpha = 4
74+
shiftAlpha %= totalNum
75+
76+
alphaShifted = None
77+
alphaShifted = charsetMain[shiftAlpha:] + charsetMain[:shiftAlpha]
78+
tableContent = str.maketrans(charsetMain, alphaShifted)
79+
80+
CIPHER_APPLIED = userChange.translate(tableContent)
81+
3982
# Pick userChange and encode it to base64
40-
userChange = base64.b64encode(userChange.encode('utf-8'))
83+
userChange = base64.b64encode(CIPHER_APPLIED.encode('utf-8'))
4184
# Save userChange to "API" file
4285
with open(relative_to_assets('Data/security/API'), 'wb') as f:
4386
# Delete everything inside the file.

0 commit comments

Comments
(0)

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /