def pwRecode(epw, oldPassword, newPassword):
 if (epw == u''):
  return epw
 if (newPassword == u''):
  (plaintext, ok) = pwDecrypt(epw)
  return (pwEncode(plaintext) if ok else epw)
 elif (oldPassword == u''):
  plaintext = pwDecode(epw)
  (cipher, ok) = pwEncrypt(plaintext, newPassword)
  return (cipher if ok else epw)
 else:
  (npw, ok) = pwReencrypt(epw, oldPassword, newPassword)
  return (npw if ok else epw)

def pwRecode ( epw , oldPassword , newPassword ) : if ( epw == u'' ) : return epw if ( newPassword == u'' ) : ( plaintext , ok ) = pwDecrypt ( epw ) return ( pwEncode ( plaintext ) if ok else epw ) elif ( oldPassword == u'' ) : plaintext = pwDecode ( epw ) ( cipher , ok ) = pwEncrypt ( plaintext , newPassword ) return ( cipher if ok else epw ) else : ( npw , ok ) = pwReencrypt ( epw , oldPassword , newPassword ) return ( npw if ok else epw )
module function to re-encode a password .