File: util.py

package info (click to toggle)
python-authlib 1.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,016 kB
  • sloc: python: 26,998; makefile: 53; sh: 14
file content (12 lines) | stat: -rw-r--r-- 262 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
import binascii


def encode_int(num, bits):
    length = ((bits + 7) // 8) * 2
    padded_hex = f"{num:0{length}x}"
    big_endian = binascii.a2b_hex(padded_hex.encode("ascii"))
    return big_endian


def decode_int(b):
    return int(binascii.b2a_hex(b), 16)