File: test_dhcrypto.py

package info (click to toggle)
python-secretstorage 3.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 252 kB
  • sloc: python: 762; makefile: 11; sh: 8
file content (20 lines) | stat: -rw-r--r-- 624 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Tests for SecretStorage
# Author: Dmitry Shachnev, 2014-2025
# License: 3-clause BSD, see LICENSE file

# This file tests the dhcrypto module.

import unittest

from secretstorage.dhcrypto import int_to_bytes


class ConversionTest(unittest.TestCase):
    """A test case that tests conversion functions
    between bytes and long."""

    def test_int_to_bytes(self) -> None:
        self.assertEqual(int_to_bytes(1, 1), b'\x01')
        self.assertEqual(int_to_bytes(1, 2), b'\x00\x01')
        self.assertEqual(int_to_bytes(258, 2), b'\x01\x02')
        self.assertEqual(int_to_bytes(1 << 64, 9), b'\x01' + b'\x00' * 8)