async def aristocrat(self, ctx): plaintext = quote.getQuote() key = makeKey() keyMap = dict(zip(alphabet, key)) ciphertext = ''.join(keyMap.get(c.lower(), c) for c in plaintext) await ctx.send(f'Ciphertext: {ciphertext}') db.writeplaintext(ctx.message.author.id, plaintext)
async def atbash(self, ctx): ciphertext = "" plaintext = quote.getQuote() for l in plaintext: if ('a' <= l <= 'z'): ciphertext += chr(122 - ord(l) + 97) if('A' <= l <= 'Z'): ciphertext += chr(90 - ord(l) + 65) if (l in punctuations): ciphertext += l await ctx.send(f'Ciphertext: {ciphertext}') db.writeplaintext(ctx.message.author.id, plaintext)
async def affine(self, ctx): a = random.choice(a_vals) b = random.randint(0, 25) ciphertext = "" plaintext = quote.getQuote() for l in plaintext: if 'a' <= l <= 'z': ciphertext += chr(((a * (ord(l) - 97) + b) % 26) + 97) if 'A' <= l <= 'Z': ciphertext += chr(((a * (ord(l) - 65) + b) % 26) + 65) if l in punctuations: ciphertext += l await ctx.send(f'Ciphertext: {ciphertext}\nA: {a}\nB: {b}') db.writeplaintext(ctx.message.author.id, plaintext)
async def caesar(self,ctx): plaintext = quote.getQuote() ciphertext = "" shift = random.randint(1,25) for l in list(plaintext): if ('a' <= l <= 'z'): ciphertext += chr((((ord(l) - 97) + shift) % 26)+97) if('A' <= l <= 'Z'): ciphertext += chr((((ord(l) - 65) + shift) % 26)+65) if(l in punctuations): ciphertext += l await ctx.send(f'Ciphertext: {ciphertext}') db.writeplaintext(ctx.message.author.id, plaintext) return [plaintext,ciphertext]
async def pollux(self,ctx): plaintext = quote.getQuote() morsecode = morse(plaintext.upper()).replace(" ", "x") # morsecode always has an x at the end? Should it be like this? digitsymbols = ["x","-","."] key = [random.choice(digitsymbols) for i in range(9)] ciphertext = "" for n in morsecode: ciphertext += str(random.choice([i for i, x in enumerate(key) if x == n])) ciphertext = ' '.join([ciphertext[i:i+5] for i in range(0, len(ciphertext), 5)]) for i in range(random.randint(0,3)): key[key.index(random.choice(key))] = "?" await ctx.send(f'Ciphertext: {ciphertext}\nKey: {key}') db.writeplaintext(ctx.message.author.id, plaintext)