def hashing(plaintext, salt='', sha='512'):
 app = webapp2.get_app()
 if (sha == '1'):
  phrase = hashlib.sha1()
 elif (sha == '256'):
  phrase = hashlib.sha256()
 else:
  phrase = hashlib.sha512()
 phrase.update(('%s@%s' % (plaintext, salt)))
 phrase_digest = phrase.hexdigest()
 try:
  from Crypto.Cipher import AES
  mode = AES.MODE_CBC
  iv = phrase_digest[:16]
  encryptor = AES.new(app.config.get('aes_key'), mode, iv)
  ciphertext = [encryptor.encrypt(chunk) for chunk in chunks(phrase_digest, 16)]
  return ''.join(ciphertext)
 except Exception as e:
  logging.error('CRYPTO is not running: {}'.format(e))
  raise

def hashing ( plaintext , salt = '' , sha = '512' ) : app = webapp2 . get_app ( ) if ( sha == '1' ) : phrase = hashlib . sha1 ( ) elif ( sha == '256' ) : phrase = hashlib . sha256 ( ) else : phrase = hashlib . sha512 ( ) phrase . update ( ( '%s@%s' % ( plaintext , salt ) ) ) phrase_digest = phrase . hexdigest ( ) try : from Crypto . Cipher import AES mode = AES . MODE_CBC iv = phrase_digest [ : 16 ] encryptor = AES . new ( app . config . get ( 'aes_key' ) , mode , iv ) ciphertext = [ encryptor . encrypt ( chunk ) for chunk in chunks ( phrase_digest , 16 ) ] return '' . join ( ciphertext ) except Exception as e : logging . error ( 'CRYPTO is not running: {}' . format ( e ) ) raise
returns the hashed and encrypted hexdigest of a plaintext and salt .