File: utils_test.py

package info (click to toggle)
olm 3.2.16%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,208 kB
  • sloc: cpp: 15,245; ansic: 10,894; java: 3,244; objc: 2,291; javascript: 1,882; python: 1,839; makefile: 439; sh: 245; asm: 7; xml: 1
file content (23 lines) | stat: -rw-r--r-- 544 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import base64
import hashlib

from olm import sha256
from olm._compat import to_bytes


class TestClass(object):
    def test_sha256(self):
        input1 = "It's a secret to everybody"
        input2 = "It's a secret to nobody"

        first_hash = sha256(input1)
        second_hash = sha256(input2)

        hashlib_hash = base64.b64encode(
            hashlib.sha256(to_bytes(input1)).digest()
        )

        hashlib_hash = hashlib_hash[:-1].decode()

        assert first_hash != second_hash
        assert hashlib_hash == first_hash