def dataEncrypt(data, password, keyLength=32, hashIterations=10000):
 from .py3AES import encryptData
 from .py3PBKDF2 import hashPasswordTuple
 (digestname, iterations, salt, hash) = hashPasswordTuple(password, iterations=hashIterations)
 key = hash[:keyLength]
 try:
  cipher = encryptData(key, data)
 except ValueError:
  return ('', False)
 return ((CryptoMarker.encode() + Delimiter.encode().join([digestname.encode(), str(iterations).encode(), base64.b64encode(salt), base64.b64encode(cipher)])), True)

def dataEncrypt ( data , password , keyLength = 32 , hashIterations = 10000 ) : from . py3AES import encryptData from . py3PBKDF2 import hashPasswordTuple ( digestname , iterations , salt , hash ) = hashPasswordTuple ( password , iterations = hashIterations ) key = hash [ : keyLength ] try : cipher = encryptData ( key , data ) except ValueError : return ( '' , False ) return ( ( CryptoMarker . encode ( ) + Delimiter . encode ( ) . join ( [ digestname . encode ( ) , str ( iterations ) . encode ( ) , base64 . b64encode ( salt ) , base64 . b64encode ( cipher ) ] ) ) , True )
module function to encrypt a password .