| key = s.init() | key = s.init() | ||||
| # does the actual authentication | # does the actual authentication | ||||
| print( s.auth( hashlib.sha256( ( 'Test123' + key ).encode( 'utf-8' ) ).hexdigest() ) ) | print( s.auth( hashlib.sha256( ( 'Test123' + key ).encode( 'utf-8' ) ).hexdigest() ) ) | ||||
| # tests protected method | |||||
| print( s.hello() ) | |||||
| # Print list of available methods | # Print list of available methods | ||||
| print( s.system.listMethods() ) | print( s.system.listMethods() ) |
| def auth(self, password_hash): | def auth(self, password_hash): | ||||
| combined = CHAP.test_password + self.key | combined = CHAP.test_password + self.key | ||||
| passhash = hashlib.sha256( combined.encode( 'utf-8' ) ).hexdigest() | passhash = hashlib.sha256( combined.encode( 'utf-8' ) ).hexdigest() | ||||
| print( passhash ) | |||||
| print( password_hash ) | |||||
| self.authenticated = passhash == password_hash | self.authenticated = passhash == password_hash | ||||
| return self.authenticated | return self.authenticated | ||||