Last active
December 1, 2022 11:10
-
-
Save b1ek/43193d4befa23c0b9653d0d1cff4a6b4 to your computer and use it in GitHub Desktop.
Python C string encryption
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random as r, time as t | |
STRING = 'You are gay\n'; | |
offset = r.randint(0, 10000); | |
encryptS = list(); | |
c = 0; | |
def rands(sz): return ''.join(r.choices(list('abcdef1234567890'), k=sz)); | |
for i in STRING: | |
encryptS.append(ord(i) * offset); | |
s1 = 's_' + rands(8); | |
s2 = 's_' + rands(8); | |
print('// #define uint64_t unsigned long long int'); | |
print(f'uint64_t {s1}[{len(encryptS) + 1}] = ' + str(encryptS).replace('[', '{').replace(']', '}') + ';'); | |
print(f'char {s2}[{len(encryptS) + 1}];'); | |
print(f'for (size_t i = 0; i != {len(encryptS)}; i++)' + ' {') | |
print(f' {s2}[i] = (int) ({s1}[i] / {offset});'); | |
print('}'); | |
print(f'{s2}[{len(encryptS)}] = \'\\0\';'); | |
print('\n// Your string is in variable ' + s2); | |
print(f'// #define string {s2}'); | |
print('// To set the string, open the file and put your string at line 3'); | |
if (os.name == 'nt'): | |
while 1: | |
try: t.sleep(0xffff); | |
except KeyboardInterrupt: exit(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment