Add Technical/picoCTF/t1/q2.md
This commit is contained in:
parent
e5482e2765
commit
0a4f528785
33
Technical/picoCTF/t1/q2.md
Normal file
33
Technical/picoCTF/t1/q2.md
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
Question: Easy1
|
||||||
|
Key: picoCTF{CRYPTOISFUN}
|
||||||
|
|
||||||
|
Core concept: Vignere Cypher - Decrypted character=(Encrypted character−Key character+26)mod26
|
||||||
|
|
||||||
|
Can be solved by an easy Python script:
|
||||||
|
|
||||||
|
```py
|
||||||
|
def decrypt_vigenere(encrypted_text, key):
|
||||||
|
decrypted_text = ""
|
||||||
|
key_length = len(key)
|
||||||
|
|
||||||
|
for i in range(len(encrypted_text)):
|
||||||
|
encrypted_char_pos = ord(encrypted_text[i]) - ord('A')
|
||||||
|
key_char_pos = ord(key[i % key_length]) - ord('A')
|
||||||
|
|
||||||
|
decrypted_char_pos = (encrypted_char_pos - key_char_pos + 26) % 26
|
||||||
|
|
||||||
|
decrypted_char = chr(decrypted_char_pos + ord('A'))
|
||||||
|
|
||||||
|
decrypted_text += decrypted_char
|
||||||
|
|
||||||
|
return decrypted_text
|
||||||
|
|
||||||
|
|
||||||
|
encrypted_flag = "UFJKXQZQUNB"
|
||||||
|
key = "SOLVECRYPTO"
|
||||||
|
|
||||||
|
decrypted_flag = decrypt_vigenere(encrypted_flag, key)
|
||||||
|
print("Decrypted Flag:", decrypted_flag)
|
||||||
|
```
|
||||||
|
|
||||||
|
Output: CRYPTOISFUN
|
Loading…
Reference in New Issue
Block a user