unfriendly/utils.py
def encrypt(plaintext, secret, inital_vector, checksum=True, lazy=True):
    """Encrypts plaintext with secret
    plaintext      - content to encrypt
    secret         - secret to encrypt plaintext
    inital_vector  - initial vector
    lazy           - pad secret if less than legal blocksize (default: True)
    checksum       - attach crc32 byte encoded (default: True)
    returns ciphertext
    """
    if not isinstance(plaintext, six.binary_type):
        plaintext = six.b(plaintext)

    secret = _lazysecret(secret) if lazy else secret
    encobj = AES.new(secret, AES.MODE_CFB, inital_vector)

    if checksum:
        packed = _pack_crc(plaintext)
        plaintext += base64.urlsafe_b64encode(packed)

    encoded = base64.urlsafe_b64encode(encobj.encrypt(plaintext))
    if isinstance(plaintext, six.binary_type):
        encoded = encoded.decode()

    return encoded.replace('=', '')
def encrypt(plaintext, secret, inital_vector, checksum=True, lazy=True):
    """Encrypts plaintext with secret
    plaintext      - content to encrypt
    secret         - secret to encrypt plaintext
    inital_vector  - initial vector
    lazy           - pad secret if less than legal blocksize (default: True)
    checksum       - attach crc32 byte encoded (default: True)
    returns ciphertext
    """
    if not isinstance(plaintext, six.binary_type):
        plaintext = six.b(plaintext)

    secret = _lazysecret(secret) if lazy else secret
    encobj = AES.new(secret, AES.MODE_CFB, inital_vector)

    if checksum:
        packed = _pack_crc(plaintext)
        plaintext += base64.urlsafe_b64encode(packed)

    encoded = base64.urlsafe_b64encode(encobj.encrypt(plaintext))
    if isinstance(plaintext, six.binary_type):
        encoded = encoded.decode()

    return encoded.replace('=', '')
Encrypts plaintext with secret
    plaintext      - content to encrypt
    secret         - secret to encrypt plaintext
    inital_vector  - initial vector
    lazy           - pad secret if less than legal blocksize (default: True)
    checksum       - attach crc32 byte encoded (default: True)
    returns ciphertext