# Path: typtop/pw_pkcrypto.py



from typtop.pw_pkcrypto import (
    generate_key_pair, pkencrypt, pkdecrypt,
    encrypt, decrypt, hmac256, compute_id,
    serialize_pk, serialize_sk, deserialize_sk,
    deserialize_pk, verify_pk_sk, harden_pw, verify,
    pwencrypt, pwdecrypt, pad_pw, unpad_pw
)
from base64 import urlsafe_b64encode, urlsafe_b64decode
import struct
import os
import pytest
        c = encrypt(k, m)
        assert decrypt(k, c) == m

def test_compute_id():
    pw = 'asdadf'
    sa = '0'*16
    t1 = compute_id(sa, pw)
    t2 = hmac256(sa, pw)
    assert t1 == compute_id(sa, unicode(pw))
    pw1 = 'asdadf1'
    t3 = hmac256(sa, pw1)
    assert t2 != t3
    assert t1 != compute_id(sa, pw1)

def test_verify_pk_sk():
    pk, sk = generate_key_pair()
    pks = serialize_pk(pk)
    sks = serialize_sk(sk)
    assert verify_pk_sk(pks, sks)
    assert verify_pk_sk(pk, sks)
    assert verify_pk_sk(pks, sk)
    pk1 = deserialize_pk(pks)
    assert verify_pk_sk(pk1, sk)


def test_harden_pw():
    pw = "amar hiyar majhe lukiye chile"
    sa, k, h = harden_pw(pw)
    k1 = verify(pw, sa, h)
    assert k == k1

# Path: typtop/pw_pkcrypto.py



# Path: tests/test_pw_pkcrypto2.py
from typtop.pw_pkcrypto import (
    generate_key_pair, pkencrypt, pkdecrypt,
    encrypt, decrypt, hmac256, compute_id,
    serialize_pk, serialize_sk, deserialize_sk,
    deserialize_pk, verify_pk_sk, harden_pw, verify,
    pwencrypt, pwdecrypt, pad_pw, unpad_pw
)
from base64 import urlsafe_b64encode, urlsafe_b64decode
import struct
import os
import pytest

        c = encrypt(k, m)
        assert decrypt(k, c) == m

def test_compute_id():
    pw = 'asdadf'
    sa = '0'*16
    t1 = compute_id(sa, pw)
    t2 = hmac256(sa, pw)
    assert t1 == compute_id(sa, unicode(pw))
    pw1 = 'asdadf1'
    t3 = hmac256(sa, pw1)
    assert t2 != t3
    assert t1 != compute_id(sa, pw1)

def test_verify_pk_sk():
    pk, sk = generate_key_pair()
    pks = serialize_pk(pk)
    sks = serialize_sk(sk)
    assert verify_pk_sk(pks, sks)
    assert verify_pk_sk(pk, sks)
    assert verify_pk_sk(pks, sk)
    pk1 = deserialize_pk(pks)
    assert verify_pk_sk(pk1, sk)


def test_harden_pw():
    pw = "amar hiyar majhe lukiye chile"
    sa, k, h = harden_pw(pw)
    k1 = verify(pw, sa, h)
    assert k == k1

    k2 = verify(pw[:-1], sa, h)