Post

CTFlearn - [Crypto] Vigenere Cipher

Vigenere Cipher



image


1
2
3
key : blorpy

Cipher : gwox{RgqssihYspOntqpxs}






Solution



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
c='gwox{RgqssihYspOntqpxs}'
key='blorpy'
idx=0

pt=''

for i in c:
	if i == '{' or i == '}':
		pt+=i
		continue
	
	capital = i.isupper()
	diff = ord(key[idx]) - ord('a')
	k=key[idx]
	idx=(idx+1)%len(key)

	decode = ord(i)-diff
	if decode < 97 and capital != 1: 
		decode+=26

	pt+=chr(decode)

print(pt)



This post is licensed under CC BY 4.0 by the author.