(self, password, salt, n=None, r=None, p=None)
| 589 | work_factor = 2**14 |
| 590 | |
| 591 | def encode(self, password, salt, n=None, r=None, p=None): |
| 592 | self._check_encode_args(password, salt) |
| 593 | n = n or self.work_factor |
| 594 | r = r or self.block_size |
| 595 | p = p or self.parallelism |
| 596 | hash_ = hashlib.scrypt( |
| 597 | password=force_bytes(password), |
| 598 | salt=force_bytes(salt), |
| 599 | n=n, |
| 600 | r=r, |
| 601 | p=p, |
| 602 | maxmem=self.maxmem, |
| 603 | dklen=64, |
| 604 | ) |
| 605 | hash_ = base64.b64encode(hash_).decode("ascii").strip() |
| 606 | return "%s$%d$%s$%d$%d$%s" % (self.algorithm, n, force_str(salt), r, p, hash_) |
| 607 | |
| 608 | def decode(self, encoded): |
| 609 | algorithm, work_factor, salt, block_size, parallelism, hash_ = encoded.split( |
no test coverage detected