Did I find the right examples for you? yes no

All Samples(7)  |  Call(4)  |  Derive(0)  |  Import(3)

        def make_utf8(*args):
    rv = []
    for arg in args:
        if isinstance(arg, bytes):
            rv.append(arg)
        else:
            rv.append(arg.encode('utf-8'))
    if len(rv) == 1:
        return rv[0]
    else:
        return rv
        


src/o/n/onepasswordpy-HEAD/onepassword/_pbkdf2_pycrypto.py   onepasswordpy(Download)
import Crypto.Hash.HMAC
import Crypto.Protocol.KDF
 
from .hashes import SHA1, SHA512
from .util import make_utf8
 
 
def pbkdf2_sha1(password, salt, length, iterations):
    password, salt = make_utf8(password, salt)
def pbkdf2_sha512(password, salt, length, iterations):
    password, salt = make_utf8(password, salt)
    prf = lambda p, s: Crypto.Hash.HMAC.new(p, s, digestmod=SHA512).digest()
    return Crypto.Protocol.KDF.PBKDF2(password=password, salt=salt, dkLen=length, count=iterations, prf=prf)
 

src/o/n/onepasswordpy-HEAD/onepassword/pbkdf1.py   onepasswordpy(Download)
from __future__ import absolute_import
from __future__ import print_function
 
from .util import make_utf8
 
    def __init__(self, key, salt, hash_algo=hashlib.md5, iterations=1):
        if salt is None:
            salt = b'\x00'*(int(math.ceil(len(key)/2)))
        key, salt = make_utf8(key, salt)
        self.key = key

src/o/n/onepasswordpy-HEAD/onepassword/crypt_util.py   onepasswordpy(Download)
from . import pbkdf2
from .hashes import MD5, SHA256, SHA512
from .util import make_utf8
 
 
def opdata1_decrypt_key(data, key, hmac_key, aes_size=C_AES_SIZE, ignore_hmac=False):
    """Decrypt encrypted item keys"""
    hmac_key = make_utf8(hmac_key)
    key_size = KEY_SIZE[aes_size]
    iv, cryptext, expected_hmac = struct.unpack("=16s64s32s", data)