Fix all outputs and make nickname uniform by hashing. - bitreich-bitmasquerade - Scripts for bitreich's new years eve bitmasqurade DIR Log DIR Files DIR Refs --- DIR commit 3c7bcf74961f5f7e9b2fc50b38f66d3192afe450 DIR parent 10fe2002968b12ea30bf5d5f92a5684d988c2dc3 HTML Author: Christoph Lohmann <20h@r-36.net> Date: Sun, 31 Dec 2023 15:16:55 +0100 Fix all outputs and make nickname uniform by hashing. Signed-off-by: Scarlett McAllister <no+reply@roygbyte.com> Diffstat: M atelier.dcgi | 35 ++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 12 deletions(-) --- DIR diff --git a/atelier.dcgi b/atelier.dcgi @@ -4,6 +4,8 @@ from functools import reduce import re import sys +import hashlib +import base64 geomyidae_host = "server" geomyidae_port = "port" @@ -12,7 +14,7 @@ bitmask_selection = [ '010101010101', '110001100011', '001110011100', '000010010000', '100010001001', '010010001000', '100110001110', '111111101111', '011000100010'] bitwise_selection = ['Flip', 'Set', 'Clear', 'Shift-Right', 'Shift-Left', - 'Turnaround'] + 'Turnaround'] bitwise_operations = {'Flip' : lambda a, b: a ^ b, 'Set' : lambda a, b: a | b, 'Clear' : lambda a, b: a & b, @@ -34,17 +36,17 @@ def strip_to_max_len(s): def print_nick_fail(): print("Pardon, but I'll need your name") -def print_step_1_template(nick): +def print_step_1_template(nick, hashnick): gph_menu_link = lambda s: \ - '[1|{}|atelier.dcgi?{} {}|{}|{}]'.format(s, nick, s, + '[1|{}|atelier.dcgi?{} {} {}|{}|{}]'.format(s, nick, hashnick, s, geomyidae_host, geomyidae_port) gph_links = '\n'.join(map(gph_menu_link, bitmask_selection)) with open('step_1.txt', 'r') as file: print(file.read().format(nick, gph_links)) -def print_step_2_template(nick, bitmask): +def print_step_2_template(nick, hashnick, bitmask): gph_menu_link = lambda s: \ - '[1|{}|atelier.dcgi?{} {} {}|{}|{}]'.format(s, nick, bitmask, s, + '[1|{}|atelier.dcgi?{} {} {} {}|{}|{}]'.format(s, nick, hashnick, bitmask, s, geomyidae_host, geomyidae_port) gph_links = '\n'.join(map(gph_menu_link, bitwise_selection)) with open('step_2.txt', 'r') as file: @@ -95,37 +97,46 @@ def main(args): # person's nick, and ask them to pick a bitmask from # the list printed out in the step 1 template. nick = strip_char_to_ascii_range(geomyidae_search, '!', '~') + m = hashlib.sha256() + m.update(nick.encode()) + m.update("bitmasquerade".encode()) + hashnick = base64.b64encode(m.digest()).decode() nick = strip_to_max_len(nick) + hashnick = strip_to_max_len(hashnick) if nick != '': - print_step_1_template(nick) + print_step_1_template(nick, hashnick) else: print_nick_fail() sys.exit() # Validate and clear up the input from the bitmask # selection. - if len(geomyidae_args) < 2: + if len(geomyidae_args) < 3: print_args_fail() sys.exit() nick = strip_char_to_ascii_range(geomyidae_args[0], '!', '~') nick = strip_to_max_len(nick) - bitmask = geomyidae_args[1] + hashnick = strip_char_to_ascii_range(geomyidae_args[1], '!', '~') + hashnick = strip_to_max_len(hashnick) + bitmask = geomyidae_args[2] if nick == '': print_nick_fail() sys.exit() if bitmask not in bitmask_selection: print_bitmask_fail() sys.exit() - if len(geomyidae_args) == 2: + if len(geomyidae_args) == 3: # Get the prson to choose their bitwise operation. - print_step_2_template(nick, bitmask) + print_step_2_template(nick, hashnick, bitmask) else: # - bitwise = geomyidae_args[2] + bitwise = geomyidae_args[3] if bitwise not in bitwise_selection: print_bitmask_fail() sys.exit() # Finish up by making combining the nick, bitmask, # and bitwise operation. - mask = make_mask(nick, bitmask, bitwise) + mask = str(make_mask(nick, bitmask, bitwise)) + if mask.startswith("b"): + mask = mask.replace("b", "") print_completion(nick, bitmask[:len(nick)], bitwise, mask) sys.exit()