Python Forum
Password Saver Project
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Password Saver Project
#11
can anyone tell me for choice 2 at line 74 is my first 2 steps of the code correct lines 80,81?

(Oct-11-2017, 12:31 PM)sparkz_alot Wrote:
(Oct-11-2017, 09:55 AM)jhenry Wrote: I'm using pycharm so ill look into that

Pycharm will automatically check your indentation, check the right side of the editor screen for the red and yellow 'ticks'. It will also automatically insert an indent where appropriate and, unless you changed the default settings, it will automatically convert tabs to 4 spaces. Finally, under the "Code" menu is the option for "Code Cleanup".

When I click code cleanup it doesn't do anything am i using it wrong?
Reply
#12
Did you follow the advice given in the video I posted a link to?

Whilst it is good to have Pycharm tidy up, it cannot know what you intended and can leave things at the wrong level of indentation.
I am trying to help you, really, even if it doesn't always seem that way
Reply
#13
(Oct-12-2017, 07:16 AM)gruntfutuk Wrote: Did you follow the advice given in the video I posted a link to?

Whilst it is good to have Pycharm tidy up, it cannot know what you intended and can leave things at the wrong level of indentation.

I looked at the video and I get the indentation a bit better but i'm still lost. But I still don't know if my first 2 steps of the code for choice 2 are correct here's what I currently have without any indentation errors

for i in range (len(passwords)):
            if passwordToLookup in passwords [i][0]:
                encryptionKey=-16
                def passwordunEncrypt (encryptedMessage, key):


                       unencryptedMessage = ''


                       for symbol in encryptedMessage:
                           if symbol.isalpha():
                               num = ord(symbol)
                               num -= key

                           if symbol.isupper():
                               if num > ord('Z'):

                                   num -= 26
                               elif num < ord('A'):
                                   num += 26
                               elif symbol.islower():
                                   if num > ord('z'):

                                       num -= 26
                               elif num < ord('a'):
                                   num += 26

                           unencryptedMessage += chr(num)
                       else:
                            unencryptedMessage += symbol

                       return unencryptedMessage
                       print(unencryptedMessage)
if the above steps are correct then i'm supposed to add the code for encryption (which is given) and turn in into decryption i'm told to decrypt is the exact reverse operation of encryption. I tried to turn every occurence of "encrypt" into "unencrypt" but when I run the code it doesnt return a decrypted password
Reply
#14
If exactly the same code is used to decrypt, just the key is different, then there is no reason to change the terminology as it has no functional benefit. Just call the function with negation of the key.

You could have a function called decrypt that simply calls the encryption function with the negated key.

Have you proven to yourself that the assumption is correct?

I just tried your code:

messageorg = "Mary had a little lamb. It's fleece as white as snow."
messageenc = passwordEncrypt(messageorg, encryptionKey)
messagerec  = passwordEncrypt(messageenc, -encryptionKey)
print(f'\n\norg: >{messageorg}<\nenc: >{messageenc}<\nrec: >{messagerec}<\n')
Which gave me:
org: >Mary had a little lamb. It's fleece as white as snow.<
enc: >Cqho xqt q byjjbu bqcr. Yj'i vbuusu qi mxyju qi idem.<
rec: >Mary had a little lamb. It's fleece as white as snow.<
So, that proves the encryption and decryption are identical code, just a different key. You just need to apply it to the password file appropriately.

By the way, instead of:
for i in range (len(passwords))
It is more simple to use, say:
for password in passwords:
and you can then index into the password string: password[0] instead of passwords[i][0].

Do not define a function within a for loop. A function definition should be defined on its own. You can call a function from within a for loop.
I am trying to help you, really, even if it doesn't always seem that way
Reply
#15
This is part of the instructionsi was given

Check if the name is found.  To index a list of lists you use 2 square backet sets
        #   So passwords[0][1] would mean for the first item in the list get it's 2nd item (remember, lists start at 0)
        #   So this would be 'XqffoZeo' in the password list given what is predefined at the top of the page.
        #   If you created a loop using the syntax described in step 1, then i is your 'iterator' in the list so you
        #   will want to use i in your first set of brackets.
        #
Reply
#16
Fine, you can ignore my suggestion to simplify the iteration if your teacher wishes you to understand the double indexing.

As to the rest?
I am trying to help you, really, even if it doesn't always seem that way
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python project help (Password manger using mysql) lifeofpy 2 4,589 Jul-31-2020, 06:18 PM
Last Post: deanhystad
  Python Password Saver Assignment sshellzr21 2 6,104 May-02-2020, 01:34 AM
Last Post: sshellzr21
  Password Saver Program suitec 3 8,862 Aug-17-2017, 12:26 AM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

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