decodepasswd.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/python2.7
  2. # -*- coding: utf-8 -*-
  3. """
  4. Created on Fri Nov 30 15:28:17 2018
  5. @author: dufs
  6. decode password by key
  7. """
  8. import os
  9. import logging
  10. import logging.config
  11. import jpype
  12. import os.path
  13. #logging.config.fileConfig('conf/logging.conf')
  14. #logger = logging.getLogger(__name__)
  15. logger = logging.getLogger('autocheck.decodepasswd')
  16. class DecodePassword():
  17. '''
  18. '''
  19. def __init__(self):
  20. jarpath =os.path.join(os.path.abspath('.'),'./')
  21. jvmpath=jpype.getDefaultJVMPath()
  22. #jvmpath='/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/server/libjvm.dylib'
  23. if jpype.isJVMStarted()>0:
  24. jpype.shutdownJVM()
  25. else:
  26. jpype.startJVM(jvmpath, "-ea", "-Djava.class.path=%s" % (jarpath + "testP.jar"))
  27. self.Jcls = jpype.JPackage("com.zznode.utils").DESDecryptCoder()
  28. def getdecodePassword(self, passwd, key):
  29. '''
  30. '''
  31. if passwd is None or key is None:
  32. desPass=''
  33. else:
  34. desPass=self.Jcls.decrypt(passwd, key)
  35. logger.debug("enPass = %s , desPass = %s" % (passwd, desPass))
  36. return desPass
  37. def shutdownJVM(self):
  38. jpype.shutdownJVM()
  39. if ( __name__ == "__main__"):
  40. logging.config.fileConfig("conf/logging.conf")
  41. #create logger
  42. logger = logging.getLogger("decodepassword")
  43. decpass=DecodePassword()
  44. decpass.getdecodePassword('GaE+arhkPtNsGdsQOej3hw==', 'dWx0cmEtc3RhY2s=')
  45. decpass.shutdownJVM()