import os
from jpype import *
import jpype

curPath = os.path.abspath(os.path.dirname(__file__))
rootPath = rootPath = os.path.split(curPath)[0]

startJVM(jpype.getDefaultJVMPath(), "-ea", "-Djava.class.path=%s" % rootPath + os.sep + "jar" + os.sep + "utils.jar")
jclass = JClass("com.babytree.AesUtils")


class aesUtils:

    def encrypt(self, content):
        """
        aes_ecb模式加密
        :param content:
        :return:
        """
        result = jclass.encrypt(content)
        return result

    def decrypt(self, content):
        """
        aes_ecb模式解密
        :param content:
        :return:
        """
        result = jclass.decrypt(content)
        return result


    def shutdown(self):
        """
        关闭虚拟机
        :return:
        """
        shutdownJVM()


if __name__ == '__main__':
    sign = aesUtils().encrypt("helloword")
    print("加密：", sign)
    sign2 = aesUtils().decrypt(sign)
    print("解密: ", sign2)
    aesUtils().shutdown()


