예제 #1
0
def run(Ex):
    if Ex == "1":
        A1.a()

    elif Ex == "2":
        A2.b()

    elif Ex == "3":
        A3.c()

    elif Ex == "4":
        A4.d()

    elif Ex == "5":
        A5.e()

    elif Ex == "6":
        A6.f()

    elif Ex == "7":
        A7.g()

    elif Ex == "8":
        A8.h()

    elif Ex == "9":
        A9.i()

    elif Ex == "10":
        A10.j()

    elif Ex == "intro":
        Aintro.A()

    else:
        print "Invalid Exercise"
예제 #2
0
def divisor_list(n):
    """Return the list of divisors of the given integer.

    >>> divisor_list(24)
    [1, 2, 3, 4, 6, 8, 12, 24]
    >>> divisor_list(30850)
    [1, 2, 5, 10, 25, 50, 617, 1234, 3085, 6170, 15425, 30850]
    >>> divisor_list(math.factorial(5))
    [1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 24, 30, 40, 60, 120]
    """

    factors = A5.factor_map(n)

    factor_powers = (tuple(factor ** exp for exp in range(multiple + 1)) for factor, multiple in factors.items())

    return sorted(reduce(operator.mul, data) for data in itertools.product(*factor_powers))
예제 #3
0
def divisor_count(n):
    """Compute the number of divisors for the given integer.

    >>> divisor_count(7)
    2
    >>> divisor_count(12)
    6
    >>> divisor_count(36)
    9
    >>> divisor_count(math.factorial(5))
    16
    >>> divisor_count(math.factorial(15))
    4032
    """

    # Each divisor is a product of multiples of each prime factor.
    factor_counts = A5.factor_map(n).values()

    # Compute the product of factor counts, incrementing since a factor may
    # be taken to the 0th power.
    return reduce(operator.mul, (1 + count for count in factor_counts), 1)
예제 #4
0
            box = RC4.init_box(key)
            RC4.ex_encrypt(message, box, mode)
            end = time.clock()

        elif mode == '2':
            message = RC4.get_message()
            key = RC4.get_key()
            box = RC4.init_box(key)
            RC4.ex_encrypt(message, box, mode)
        print('--------------------------RC4 end--------------------------\n')
        print('Cost ' + str(end - start) + 's\n')
        costdic[choose] = end - start
    elif choose == 8:
        print('--------------------------A5--------------------------\n')

        choice = raw_input("1 Encrypt or 2 Decode \n")
        if choice == '1':
            message = raw_input('What would you like to encrypt?\n')
            start = time.clock()
            A5.a5_encode(message)
            end = time.clock()
        elif choice == '2':
            bin_message = raw_input('What would you like to encrypt?\n')
            A5.a5_decode(bin_message)
        print('--------------------------A5--------------------------\n')
        print('Cost ' + str(end - start) + 's\n')
        costdic[choose] = end - start
    reslist = sorted(costdic.items(), key=lambda d: d[1], reverse=True)
    print('1 RSA\n2 caesar\n3 AES CBC\n4 PBE\n5 DES\n6 MD5\n7 RC4\n8 A5\n')
    print(reslist)
예제 #5
0
result = A3.evaluate(sourceCode)
if result:
    print("A3 Suspicious")
    for line in result:
        print(line)
else:
    print("A3 Benign")

result = A4.evaluate(sourceCode)
if result:
    print("A4 Suspicious")
    for line in result:
        print(line)
else:
    print("A4 Benign")

result, _ = A5.evaluate(sourceCode, homographDatabase)
if result:
    print("A5 Suspicious")
    for line in result:
        print(line)
else:
    print("A5 Benign")

result = A6_A7.evaluate(sourceCode)
if result:
    print("A6,A7 Suspicious")
    for line in result:
        print(line)
else:
    print("A6,A7 Benign")
예제 #6
0
import A5
import unittest
ex = A5.CommonAPI("A5", 400, 300)


class PwdTest(unittest.TestCase):
    def testSuccess(self):  # Test for success
        Valid = ex.PwdValidate('New1212', 'New1212')
        self.assertEqual(Valid, None)

    def testFail1(self):  # field is empty
        Fail = ex.PwdValidate('New1212', '')
        self.assertEqual(Fail, None)

    def testFail2(self):  # both fields are empty
        Fail = ex.PwdValidate('', '')
        self.assertEqual(Fail, None)

    def testFail3(self):  # password length is less than equal to 6
        Fail = ex.PwdValidate('New12', 'New12')
        self.assertEqual(Fail, None)

    def testFail4(self):  # new password and re-entered password not equal
        Fail = ex.PwdValidate('New1212', 'New121')
        self.assertEqual(Fail, None)

    def testFail5(self):  # password has non-alphanumeric characters
        Fail = ex.PwdValidate('new_12*#', 'new_12*#')
        self.assertEqual(Fail, None)

    def testFail6(self):  # Passwords have different cases
예제 #7
0
파일: main.py 프로젝트: evedour/ANN_num_rec
            'Επιλέξτε υποερώτημα: \n1  (Single-layer MLP)\n2   (Two-Layer MLP)\n3  (Early-Stopping)\n'
        )
        if rn_2 == '1':
            single_layer.single_layer(epochs)
            flag = False
        if rn_2 == '2':
            extra_layer.extra_layer(epochs)
            flag = False
        if rn_2 == '3':
            early_stopping.early_stopping(epochs)
            flag = False
    if rn == 'A3':
        A3.a3(epochs)
        flag = False
    if rn == 'A4':
        A4.a4(epochs)
        flag = False
    if rn == 'A5':
        rn_3 = input('Με ή χωρίς επίπεδο dropout; ')
        if rn_3 == 'με':
            A5_dropout.a5()
            flag = False
        else:
            A5.a5()
            flag = False
    else:
        flag = False
    check = input('Συνέχεια με άλλο ερώτημα; (Y/N)')
    if check == 'Y':
        flag = True