1

Bank vault systems that have a tactile number pad for pin entry are vulnerable to misuse by a thief. Thieves can use cameras, themselves, or even other people to view the pattern that a 4 digit pin makes when entered; therefore they do not need to know the actual value of your pin, just the sequence of button presses that will allow for entry into the system. To overcome this fatal flaw, a touchscreen display that has a number pad GUI may be used, with the keys being shuffled every time the pin is entered whether it is correct or not.

Someone has posted an answer to a similar question, but with-out the shuffle function. Need a Gui Keypad for a touchscreen that outputs a pin when code is correct

I have been playing around with the code in the answer to the question posted in the link above by trying to shuffle the list 'keys' whenever a '#' is entered but it does not work. Do you guys have any idea how to make a touchscreen GUI keypad with numbers that shuffle everyime a '#' is received?

greatgamer34
  • 35
  • 1
  • 7

1 Answers1

0

Using the same code as from the link you posted to generate the buttons matrix:

import random

keys = [
    ['1', '2', '3'],    
    ['4', '5', '6'],    
    ['7', '8', '9'],    
    ['*', '9', '#'],    
]

for key in keys:
    random.shuffle(key)
    #optionally we can also shuffle the keys list
    random.shuffle(keys)

You can use print(keys) to check for the choices on multiple runs. I'm sure there's even easier ways of doing it but this is pretty simple.

Edit: I wasn't checking for the answer of that thread initially. You can use random.shuffle(key) to partially shuffle the order of the 3 keys displayed on the keypad and an extra random.shuffle(keys) to shuffle up the list again.

Alex C.
  • 31
  • 7