• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lbryio / lbry-sdk / 10449340069

19 Aug 2024 07:49AM UTC coverage: 56.991%. Remained the same
10449340069

Pull #3741

github

web-flow
Merge dc280b71d into e7666f489
Pull Request #3741: Bump version to 0.114.0

2805 of 6558 branches covered (42.77%)

Branch coverage included in aggregate %.

5 of 5 new or added lines in 2 files covered. (100.0%)

2 existing lines in 1 file now uncovered.

12281 of 19913 relevant lines covered (61.67%)

0.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.48
/lbry/crypto/hash.py
1
import hashlib
3✔
2
import hmac
3✔
3
from binascii import hexlify, unhexlify
3✔
4

5

6
def sha256(x):
3✔
7
    """ Simple wrapper of hashlib sha256. """
8
    return hashlib.sha256(x).digest()
1✔
9

10

11
def sha512(x):
3✔
12
    """ Simple wrapper of hashlib sha512. """
13
    return hashlib.sha512(x).digest()
1✔
14

15

16
def ripemd160(x):
3✔
17
    """ Simple wrapper of hashlib ripemd160. """
18
    h = hashlib.new('ripemd160')
1✔
19
    h.update(x)
1✔
20
    return h.digest()
1✔
21

22

23
def double_sha256(x):
3✔
24
    """ SHA-256 of SHA-256, as used extensively in bitcoin. """
25
    return sha256(sha256(x))
1✔
26

27

28
def hmac_sha512(key, msg):
3✔
29
    """ Use SHA-512 to provide an HMAC. """
30
    return hmac.new(key, msg, hashlib.sha512).digest()
1✔
31

32

33
def hash160(x):
3✔
34
    """ RIPEMD-160 of SHA-256.
35
        Used to make bitcoin addresses from pubkeys. """
36
    return ripemd160(sha256(x))
1✔
37

38

39
def hash_to_hex_str(x):
3✔
40
    """ Convert a big-endian binary hash to displayed hex string.
41
        Display form of a binary hash is reversed and converted to hex. """
UNCOV
42
    return hexlify(reversed(x))
×
43

44

45
def hex_str_to_hash(x):
3✔
46
    """ Convert a displayed hex string to a binary hash. """
UNCOV
47
    return reversed(unhexlify(x))
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc