Python Forum
Write function to find decryptionkey
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Write function to find decryptionkey
#3
Assignment: Implement the function DecryptionKey(key). This function returns new_key created from the encryption key stored in key. The new key must be the key used to decrypt a text that was encrypted using key. So, when new_text = ConvertText(text, key) was used to encrypt text, then text = ConverText(new_text, new_key) can be used to decrypt new_test. Test this function.

This is the assignment, I hope things are clearer now, if not, let me know.

Now I have the following function:

def DecryptionKey(key):
    array1 = list(range(0, 26))
    Dekey = ""
    array2 = []
    for i in key:
        number = ord(i) - 97
        lijst2.append(number)
    array3 = list(zip(array1, lijst2))
    
    return array3
With output:

Output:
[(0, 16), (1, 22), (2, 4), (3, 17), (4, 19), (5, 24), (6, 20), (7, 8), (8, 14), (9, 15), (10, 0), (11, 18), (12, 3), (13, 5), (14, 6), (15, 7), (16, 9), (17, 10), (18, 11), (19, 25), (20, 23), (21, 2), (22, 21), (23, 1), (24, 13), (25, 12)]
So we have for example in the current list a tuple (0, 16). But I want a new list that has the same tuples but now (16, 9), since we have tuples (0, 16) and (16, 9) in the current list. Another example: In the current list there is a tuple (10, 0), but in the new list I want a tuple (0, 16), since in the current list we have the tuples (0, 16) and (10, 0). Anyone any idea how I could do this?

If I could create such new array in the function than I think I solved the problem
Reply


Messages In This Thread
Write function to find decryptionkey - by kotter - Dec-05-2019, 12:19 PM
RE: Write function to find decryptionkey - by buran - Dec-05-2019, 12:51 PM
RE: Write function to find decryptionkey - by kotter - Dec-05-2019, 01:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question How to Write a function with Pandas? SuperNinja3I3 4 2,450 Jul-03-2022, 02:19 PM
Last Post: ndc85430
  How can I write a function with three parameters? MehmetAliKarabulut 3 2,886 Mar-04-2021, 05:23 PM
Last Post: buran
  how to write a function in python that solves an equation samiraheen 5 9,934 Sep-28-2017, 01:10 AM
Last Post: Mekire
  Write a function sorting(L)? MoIbrahim 11 8,505 Apr-22-2017, 11:45 AM
Last Post: idontreallywolf
  function to write the contents of a webpage into a new file roadrage 4 6,166 Dec-01-2016, 09:28 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020