python basics - bound and encryption function

A base class constraints derived class
   method must be overridden added constraint
   raise NotImplementedError ( 'exception') // Standard wording
   raise Expection ( 'exception 2')
 2 A class (Object):
      DEF Send (Self):
      The raise NotImplementedError ( " The method needs to be rewritten ")
    class B (A):
      DEF the receive (Self):
      Print (" WEA ")
      C = B ()
    c.send () // if necessary constraint function will call the parent class reported abnormal
    scenarios defined group class constraints, many subclass inherits then override base class methods, for example frame re DRF (get post or the like)
3 custom exception class
    object defines a generally exception processing module class
    criteria module determines
    the try:
    the except exception AS error:
    Print ( error)
. 4 MD5 encrypted
    hashlib module
   1 obj = hashlib.md5 (b'hash unique label ') plus a unique marker color, can be globally unique, fixed die
      obj.update ( "str.encode (' utf- 8)" )//encryption
      1 which must not be interpreted as anti-byte 2
   2 v = obj.hexdigest () // get the ciphertext
     keyword hit library
     can be found if not unique tag, then online MD5 crack site is very easy to crack, to keep in mind here, you can encrypted using MD5 detection site after the completion of detecting
   the same is true 3 Comparative ciphertext unique confirmatory verification, authentication token later
     user login module
     Import hashlib
     DEF jiami (MIMA):
       obj = hashlib.md5 (b'e10adc3949ba59abbe56e057f20f23 ')
       obj.update ( mima.encode ( 'UTF-. 8'))
       miwen = obj.hexdigest ()
       return miwen
    DEF yanzheng (MIMA):
      IF jiami (MIMA) == '6230072a58128616046415141b034013':
       Print ( "authentication successful")
     the else:
       Print ( "verify failure ")
   # encryption registered
      user = input (" Please enter your user name ")
      password = the iNPUT (" Please enter your password. ")
      value=jiami(password)
    # Login
       password = input ( "Please enter your password") 
       yanzheng (password)

Guess you like

Origin www.cnblogs.com/danhuangpai/p/10944083.html