def setHashedPin(self, pin): log.debug('setHashedPin()') seed = geturandom(16) self.LinOtpSeed = unicode(binascii.hexlify(seed)) self.LinOtpPinHash = unicode(binascii.hexlify(hash(pin, seed))) return self.LinOtpPinHash
def getHashedPin(self, pin): # TODO: we could log the PIN here. log.debug('getHashedPin()') ## calculate a hash from a pin # Fix for working with MS SQL servers # MS SQL servers sometimes return a '<space>' when the column is empty: '' seed_str = self._fix_spaces(self.LinOtpSeed) seed = binascii.unhexlify(seed_str) hPin = hash(pin, seed) log.debug("[getHashedPin] hPin: %s, pin: %s, seed: %s" % (binascii.hexlify(hPin), pin, self.LinOtpSeed)) return binascii.hexlify(hPin)
def getHashedPin(self, pin): # TODO: we could log the PIN here. log.debug('getHashedPin()') ## calculate a hash from a pin # Fix for working with MS SQL servers # MS SQL servers sometimes return a '<space>' when the column is empty: '' seed_str = self._fix_spaces(self.LinOtpSeed or '') seed = binascii.unhexlify(seed_str) hPin = hash(pin, seed) log.debug("[getHashedPin] hPin: %s, pin: %s, seed: %s" % (binascii.hexlify(hPin), pin, self.LinOtpSeed or '')) return binascii.hexlify(hPin)