Skip to content

Commit

Permalink
Make it better
Browse files Browse the repository at this point in the history
  • Loading branch information
drygdryg committed Aug 16, 2019
1 parent e6d63ff commit 6729f80
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions WPSpin.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _parseMac(self, mac):
mac = int(mac, 16)
return mac

def _checksum(self, pin):
def checksum(self, pin):
'''
Standard WPS checksum algorithm.
@pin — A 7 digit pin to calculate the checksum for.
Expand All @@ -84,7 +84,7 @@ def generate(self, algo, mac):
if algo == 'pinEmpty':
return pin
pin = pin % 10000000
pin = str(pin) + str(self._checksum(pin))
pin = str(pin) + str(self.checksum(pin))
return pin.zfill(8)

def getAll(self, mac, get_static=True):
Expand All @@ -105,6 +105,14 @@ def getAll(self, mac, get_static=True):
res.append(item)
return res

def getList(self, mac, get_static=True):
res = []
for ID, algo in self.algos.items():
if algo['mode'] == self.ALGO_STATIC and not get_static:
continue
res.append(self.generate(ID, mac))
return res

def pin24(self, mac):
return (mac & 0xFFFFFF)

Expand Down

0 comments on commit 6729f80

Please sign in to comment.