Exemplo n.º 1
0
def encrypting(message, key):
    from string import printable
    encrypted = printable[printable.find(message[-1]) + key % 9 -
                          printable.find(message[0])]
    for i in range(1, len(message)):
        encrypted += printable[printable.find(encrypted[i - 1]) + key % 9 -
                               printable.find(message[i])]
    encrypted = ''.join(encrypted)
    return encrypted
Exemplo n.º 2
0
def decrypting(encrypted, key):
    from string import printable
    decrypted = list(
        map(
            lambda x: printable[printable.find(encrypted[x - 1]) + key % 9 -
                                printable.find(encrypted[x])],
            reversed(range(len(encrypted)))))
    decrypted = ''.join(reversed(decrypted))
    decrypted = printable[printable.find(decrypted[-1]) + key % 9 -
                          printable.find(encrypted[0])] + decrypted[1:]
    return decrypted
    def __constructID(self, name, facetuniquename):
        """ Method that calculates a unique id for each facetvalue, for better identification.
            This consitutes a non-stochastic method to maintain the IDs of values across systems, and thus being able to
            pass around URL-queries for the faceted browser.
            Note that an ID for faceted browser values is not related at all to the ID of the object in the database!

            DJF_URL_AS_NUMBERS = False:
                A combination of facet uniquename and value name must be unique: eg 'religionname_Protestant'

            DJF_URL_AS_NUMBERS = True:
                We take the string above and transform it into a number.

         """
        exit = ""
        if DJF_URL_AS_NUMBERS:
            bigstring = force_unicode(name) + force_unicode(facetuniquename)
            for el in bigstring.replace(" ", ""):
                try:
                    exit += force_unicode(POSSIBLE_CHARACTERS.find(el) + 1)
                except:
                    exit += '999'
            return int(exit)
        else:
            bigstring = force_unicode(facetuniquename) + u"_" + force_unicode(name)
            return bigstring.replace(" ", "")
Exemplo n.º 4
0
def decrypt(cipher, key):
    plain_text = []
    for c in cipher:
        position = letters.find(c)
        position = (position - key) % len(letters)
        plain_text.append(letters[position])
    return ''.join(plain_text)
Exemplo n.º 5
0
    def __constructID(self, name, facetuniquename):
        """ Method that calculates a unique id for each facetvalue, for better identification.
			This consitutes a non-stochastic method to maintain the IDs of values across systems, and thus being able to
			pass around URL-queries for the faceted browser.
			Note that an ID for faceted browser values is not related at all to the ID of the object in the database!
			
			DJF_URL_AS_NUMBERS = False:
				A combination of facet uniquename and value name must be unique: eg 'religionname_Protestant'
				
			DJF_URL_AS_NUMBERS = True:
				We take the string above and transform it into a number.
			 
		 """
        exit = ""
        if DJF_URL_AS_NUMBERS:
            bigstring = force_unicode(name) + force_unicode(facetuniquename)
            for el in bigstring.replace(" ", ""):
                try:
                    exit += force_unicode(POSSIBLE_CHARACTERS.find(el) + 1)
                except:
                    exit += '999'
            return int(exit)
        else:
            bigstring = force_unicode(facetuniquename) + u"_" + force_unicode(
                name)
            return bigstring.replace(" ", "")
Exemplo n.º 6
0
def encrypt(message="Hello", key=3):
    cipher = []
    for i in message:
        index = letters.find(i)
        new_index = (index + key) % len(letters)
        cipher_char = letters[new_index]
        cipher.append(cipher_char)
    return cipher
Exemplo n.º 7
0
def decrypt(en="khoor", key=3):
    plain = []
    for i in en:
        index = letters.find(i)
        new_index = (index - key) % len(letters)
        plain_char = letters[new_index]
        plain.append(plain_char)
    return plain
Exemplo n.º 8
0
def encrypt(message, key):
    cipher = []  # List equivelent to array
    for c in message:
        position = letters.find(c)
        new_position = position + key % len(letters)
        encrypted_char = letters[new_position]
        cipher.append(encrypted_char)

    return ''.join(cipher)
Exemplo n.º 9
0
def caser_decrypt(cipher, key):
    plainText = []
    for a in cipher:
        position = letters.find(a)
        newPosition = position - key % len(letters)
        decrypt = letters[newPosition]
        plainText.append(plainText)

    return ''.join(plainText)
Exemplo n.º 10
0
def caser_encrypt(message, key):
    cipher = []
    for a in message:
        position = letters.find(a)
        newPosition = position + key % len(letters)
        encrypt = letters[newPosition]
        cipher.append(encrypt)

    return ''.join(cipher)
Exemplo n.º 11
0
    b = None
    while i > 0:
        prime(i)
        i = int(i / int(no[:-1]))
        if i > 1:
            b = i
    return b


num = 3
ar = list()
for j in range(1, len(printable)):
    temp = ""
    for i in range(len(flag)):
        #number()
        temp += printable[(printable.find(flag[i]) + j) % len(printable)]
    ar.append(temp)
    print(temp)
print("\n")

position = list()
for i in range(len(flag)):
    check = False
    for j in range(len(ar)):
        for k in range(len(ar[j])):
            if (ar[j][k] == flag[i]):
                position.append([i, j, k])
                check = True
                break
        if check == True:
            break
Exemplo n.º 12
0
# for i in range(len(a)):
# 	if(i%3==0):
# 		real_arr.append(a[i])
# 	if(i%3==1):
# 		real_arr.append(a[i])
# 	if(i%3==2):
# 		real_arr.append(a[i])
# print real_arr

# for i in real_arr:
# 	flag[i[0]]=decode_arr[i[1]][i[2]]
# print ''.join(flag)

decode_arr=[]
for j in range(1,len(printable)):
	tmp=base64.b64decode(list_b64[j-1])
	tmp2=""
	for i in tmp:
		tmp2+=printable[(printable.find(i)-j)%len(printable)]
	if(j!=1):
		assert(tmp2==decode_arr[j-2])
	decode_arr.append(tmp2)
flag=""
for i in decode_arr[0]:
	if i=='b':
		flag+="y"
	elif i in ascii_letters:
		flag+=chr(ord(i)-3)
	else:
		flag+=i
print flag
Exemplo n.º 13
0
    else:
        return True


Nombre = 1
while True:
    x = ".{" + str(Nombre) + "}"
    if not check(x): break
    Nombre = Nombre + 1
length = Nombre - 1
origin = ""
i = 1
while not (i > length):
    for car in printable:
        if car == "*" or car == "(" or car == ")": continue
        if printable.find(car) >= 62: car = "\\" + car
        x = "^" + origin + car
        if check(x): break
    origin += car
    print(origin)
    i += 1
print(origin)
password = ""
i = 0
while not (i > len(origin) - 1):
    if origin[i] == "\\":
        password = password + origin[i + 1]
        i += 1
    else:
        password = password + origin[i]
    i += 1