def pwEncrypt(pw, masterPW=None):
 if (masterPW is None):
  if (MasterPassword is None):
   __getMasterPassword()
   if (MasterPassword is None):
    return (u'', False)
  masterPW = pwDecode(MasterPassword)
 from .py3PBKDF2 import hashPasswordTuple
 (digestname, iterations, salt, hash) = hashPasswordTuple(masterPW)
 key = hash[:32]
 from .py3AES import encryptData
 try:
  cipher = encryptData(key, pw.encode(u'utf-8'))
 except ValueError:
  return (u'', False)
 return ((CryptoMarker + Delimiter.join([digestname, str(iterations), base64.b64encode(salt).decode(u'ascii'), base64.b64encode(cipher).decode(u'ascii')])), True)

def pwEncrypt ( pw , masterPW = None ) : if ( masterPW is None ) : if ( MasterPassword is None ) : __getMasterPassword ( ) if ( MasterPassword is None ) : return ( u'' , False ) masterPW = pwDecode ( MasterPassword ) from . py3PBKDF2 import hashPasswordTuple ( digestname , iterations , salt , hash ) = hashPasswordTuple ( masterPW ) key = hash [ : 32 ] from . py3AES import encryptData try : cipher = encryptData ( key , pw . encode ( u'utf-8' ) ) except ValueError : return ( u'' , False ) return ( ( CryptoMarker + Delimiter . join ( [ digestname , str ( iterations ) , base64 . b64encode ( salt ) . decode ( u'ascii' ) , base64 . b64encode ( cipher ) . decode ( u'ascii' ) ] ) ) , True )
module function to encrypt a password .