Example #1
0
    def __init__(self, core, mu, c, weights):
        """Initializes the concept."""

        if (not isinstance(core, cor.Core)) or (not cor.check(core._cuboids, core._domains)):
            raise Exception("Invalid core")

        if mu > 1.0 or mu <= 0.0:
            raise Exception("Invalid mu")
        
        if c <= 0.0:
            raise Exception("Invalid c")
        
        if (not isinstance(weights, wghts.Weights)) or (not wghts.check(weights._domain_weights, weights._dimension_weights)):
            raise Exception("Invalid weights")
        
        self._core = core
        self._mu = mu
        self._c = c
        self._weights = weights
Example #2
0
 def test_birthday_format_ok(self):
     self.assertEqual(0, core.check({'birthday': '12.12.2001'}),
                      "checking bthday")
Example #3
0
    args = parser.parse_args()

    # 获取必要信息
    key = args.k
    s = args.s
    if key == None:
        from getpass import getpass
        key = getpass("请输入key(已隐藏输入内容): ")
    if s == None:
        try:
            s = ""
            while 1:
                s = s + "\n" + input()
        except EOFError:
            pass

    # 基本加密解密
    if args.ext != None:
        if core.check(s) or core.check(key):
            print("有输入不合法!")
        if args.enc:
            print(core.encrypt(key, s))
        else:
            print(core.decrypt(key, s))

    # 调用扩展
    pass

except InterruptedError:
    print("用户退出")
    sys.exit(0)
Example #4
0
 def test_phone_format_ok(self):
     self.assertEqual(0, core.check({'phone': '+79867678696'}),
                      "checking phone")
Example #5
0
 def test_arg_format_ok(self):
     self.assertEqual(0, core.check({'name': 'Vitalyu'}), "checking name")
Example #6
0
 def test_birthday_format(self):
     self.assertEqual(1, core.check({'birthday': '12.22.3001'}),
                      "checking bthday")
Example #7
0
 def test_phone_format(self):
     self.assertEqual(1, core.check({'phone': '+70000000op09'}),
                      "checking phone")
Example #8
0
 def test_arg_format(self):
     self.assertEqual(1, core.check({'name': '$%ET09'}), "checking name")