Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Hacker Language by tokiojapan55
import re
class HackerLanguage:
WHITE_SPACE_CRYPT = '1000000'
text = ''
def write(self, text):
self.text += text
def delete(self, n):
self.text = self.text[:-n]
def send(self):
return self.encrypt(self.text)
def read(self, text):
return self.decrypt(text)
def encrypt(self, text):
result = ''
for c in text:
if c.isalpha():
result += str(bin(ord(c)))[2:]
elif c == ' ':
result += HackerLanguage.WHITE_SPACE_CRYPT
else:
result += c
return result
def decrypt(self, text):
result = ''
while True:
if len(text) < 7:
result += text
break
if text[:len(HackerLanguage.WHITE_SPACE_CRYPT)] == HackerLanguage.WHITE_SPACE_CRYPT:
result += ' '
text = text[len(HackerLanguage.WHITE_SPACE_CRYPT):]
elif self.is_encrypted_alphabet(text[:7]):
result += chr(int('0b' + text[:7], 0))
text = text[7:]
else:
result += text[0]
text = text[1:]
return result
def is_encrypted_alphabet(self, text):
if len(text) == 7:
if {'0', '1'}.issuperset(set(list(text))):
a = int('0b' + text, 0)
if ord('a') <= a <= ord('z') or ord('A') <= a <= ord('Z'):
return True
return False
May 26, 2020
Comments: