ucscsdk/ucscgenutils.py
def encrypt_password(password, key):
    """
    Encrypts the password using the given key.

    Args:
        password (str): password to be encrypted
        key (str): key to be used to encrypt the password
    """

    from time import time
    from array import array
    import hmac
    import base64

    try:
        xrange
    except:
        xrange = range

    h_hash = get_sha_hash
    uhash = h_hash(','.join(str(x) for x in
                            [repr(time()), repr(os.getpid()),
                             repr(len(password)),
                             password, key]))[:16]
    k_enc, k_auth = h_hash('enc' + key + uhash), h_hash('auth' + key + uhash)
    pwd_len = len(password)
    password_stream = array('L', password + '0000'[pwd_len & 3:])
    x_key = expand_key(k_enc, pwd_len + 4)

    for i_cnt in xrange(len(password_stream)):
        password_stream[i_cnt] = password_stream[i_cnt] ^ x_key[i_cnt]

    cipher_t = uhash + password_stream.tostring()[:pwd_len]
    auth = hmac.new(cipher_t, k_auth).digest()
    encrypt_str = cipher_t + auth[:8]
    encoded_str = base64.encodestring(encrypt_str)
    encrypted_password = encoded_str.rstrip('\n')
    return encrypted_password

    Encrypts the password using the given key.

    Args:
        password (str): password to be encrypted
        key (str): key to be used to encrypt the password
    
Encrypts the password using the given key.
Encrypts the password using the given key .
def encrypt_password(password, key):
    from time import time
    from array import array
    import hmac
    import base64
    try:
        xrange
    except:
        xrange = range
    h_hash = get_sha_hash
    uhash = h_hash(','.join(str(x) for x in
                            [repr(time()), repr(os.getpid()),
                             repr(len(password)),
                             password, key]))[:16]
    k_enc, k_auth = h_hash('enc' + key + uhash), h_hash('auth' + key + uhash)
    pwd_len = len(password)
    password_stream = array('L', password + '0000'[pwd_len & 3:])
    x_key = expand_key(k_enc, pwd_len + 4)
    for i_cnt in xrange(len(password_stream)):
        password_stream[i_cnt] = password_stream[i_cnt] ^ x_key[i_cnt]
    cipher_t = uhash + password_stream.tostring()[:pwd_len]
    auth = hmac.new(cipher_t, k_auth).digest()
    encrypt_str = cipher_t + auth[:8]
    encoded_str = base64.encodestring(encrypt_str)
    encrypted_password = encoded_str.rstrip('\n')
    return encrypted_password
def encrypt_password ( password , key ) : from time import time from array import array import hmac import base64 try : xrange except : xrange = range h_hash = get_sha_hash uhash = h_hash ( ',' . join ( str ( x ) for x in [ repr ( time ( ) ) , repr ( os . getpid ( ) ) , repr ( len ( password ) ) , password , key ] ) ) [ : 16 ] k_enc , k_auth = h_hash ( 'enc' + key + uhash ) , h_hash ( 'auth' + key + uhash ) pwd_len = len ( password ) password_stream = array ( 'L' , password + '0000' [ pwd_len & 3 : ] ) x_key = expand_key ( k_enc , pwd_len + 4 ) for i_cnt in xrange ( len ( password_stream ) ) : password_stream [ i_cnt ] = password_stream [ i_cnt ] ^ x_key [ i_cnt ] cipher_t = uhash + password_stream . tostring ( ) [ : pwd_len ] auth = hmac . new ( cipher_t , k_auth ) . digest ( ) encrypt_str = cipher_t + auth [ : 8 ] encoded_str = base64 . encodestring ( encrypt_str ) encrypted_password = encoded_str . rstrip ( '\n' ) return encrypted_password
Encrypts the password using the given key.
Encrypts the password using the given key .
"""
    Encrypts the password using the given key.

    Args:
        password (str): password to be encrypted
        key (str): key to be used to encrypt the password
    """
password
password to be encrypted
password to be encrypted
key
key to be used to encrypt the password
key to be used to encrypt the password