pyauth / pyotp
Showing 2 of 3 files from the diff.

@@ -14,7 +14,7 @@
Loading
14 14
        self,
15 15
        s: str,
16 16
        digits: int = 6,
17 -
        digest: Any = hashlib.sha1,
17 +
        digest: Any = None,
18 18
        name: Optional[str] = None,
19 19
        issuer: Optional[str] = None,
20 20
        initial_count: int = 0,
@@ -23,10 +23,13 @@
Loading
23 23
        :param s: secret in base32 format
24 24
        :param initial_count: starting HMAC counter value, defaults to 0
25 25
        :param digits: number of integers in the OTP. Some apps expect this to be 6 digits, others support more.
26 -
        :param digest: digest function to use in the HMAC (expected to be sha1)
26 +
        :param digest: digest function to use in the HMAC (expected to be SHA1)
27 27
        :param name: account name
28 28
        :param issuer: issuer
29 29
        """
30 +
        if digest is None:
31 +
            digest = hashlib.sha1
32 +
30 33
        self.initial_count = initial_count
31 34
        super().__init__(s=s, digits=digits, digest=digest, name=name, issuer=issuer)
32 35

@@ -17,7 +17,7 @@
Loading
17 17
        self,
18 18
        s: str,
19 19
        digits: int = 6,
20 -
        digest: Any = hashlib.sha1,
20 +
        digest: Any = None,
21 21
        name: Optional[str] = None,
22 22
        issuer: Optional[str] = None,
23 23
        interval: int = 30,
@@ -26,10 +26,13 @@
Loading
26 26
        :param s: secret in base32 format
27 27
        :param interval: the time interval in seconds for OTP. This defaults to 30.
28 28
        :param digits: number of integers in the OTP. Some apps expect this to be 6 digits, others support more.
29 -
        :param digest: digest function to use in the HMAC (expected to be sha1)
29 +
        :param digest: digest function to use in the HMAC (expected to be SHA1)
30 30
        :param name: account name
31 31
        :param issuer: issuer
32 32
        """
33 +
        if digest is None:
34 +
            digest = hashlib.sha1
35 +
33 36
        self.interval = interval
34 37
        super().__init__(s=s, digits=digits, digest=digest, name=name, issuer=issuer)
35 38
@@ -37,7 +40,9 @@
Loading
37 40
        """
38 41
        Accepts either a Unix timestamp integer or a datetime object.
39 42
40 -
        To get the time until the next timecode change (seconds until the current OTP expires), use this instead::
43 +
        To get the time until the next timecode change (seconds until the current OTP expires), use this instead:
44 +
45 +
        .. code:: python
41 46
42 47
            totp = pyotp.TOTP(...)
43 48
            time_remaining = totp.interval - datetime.datetime.now().timestamp() % totp.interval
Files Coverage
src/pyotp 98.07%
Project Totals (8 files) 98.07%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading