Exemplo n.º 1
0
def buildClipUrl(url, token):
    # pyCrypto
    # dec = AES.new(aes_key[0].decode('hex'), AES.MODE_CBC, aes_key[1].decode('hex'))
    # path = dec.decrypt(base64.b64decode(token['tokenValue']))
    # query = token['tokenName'] + '=' + path2[0:len(path2)-7]
    #
    # cryptopy
    dec = aes_cbc.AES_CBC(key=aes_key[0].decode('hex'), keySize=16)
    path = dec.decrypt(base64.b64decode(token['tokenValue']), iv=aes_key[1].decode('hex'))
    query = token['tokenName'] + '=' + path
    return url + '?' + query
Exemplo n.º 2
0
 def __decrypt(self, secretServer, data):
     """
     Decrypts the data from the server using the provided token
     :param secretServer: 
     :param data:
     """
     iv = secretServer[:len(secretServer) // 2]
     key = secretServer[len(secretServer) // 2:]
     decryptor = aes_cbc.AES_CBC(key)
     decrypted_data = decryptor.decrypt(base64.b64decode(data), iv=iv)
     return decrypted_data
Exemplo n.º 3
0
 def buildClipUrl(self, url, token):
     # pyCrypto
     # dec = AES.new(self.aes_key[0].decode('hex'), AES.MODE_CBC, self.aes_key[1].decode('hex'))
     # path = dec.decrypt(base64.b64decode(token['tokenValue']))
     # query = '{0}={1}'.format(token['tokenName'], path2[0:len(path2)-7])
     #
     # cryptopy
     dec = aes_cbc.AES_CBC(key=self.aes_key[0].decode('hex'), keySize=16)
     path = dec.decrypt(base64.b64decode(token['tokenValue']),
                        iv=self.aes_key[1].decode('hex'))
     query = '{0}={1}'.format(token['tokenName'], path)
     return '{0}?{1}'.format(url, query)
Exemplo n.º 4
0
 def __encrypt(self, secretServer, data):
     """
     Encrypts the data from the server using the provided token
     :param secretServer: 
     :param data:
     """
     data = pad(data.encode('utf-8'))
     iv = secretServer[:len(secretServer) // 2]
     key = secretServer[len(secretServer) // 2:]
     encryptor = aes_cbc.AES_CBC(key)
     encrypted_data = base64.b64encode(encryptor.encrypt(data, iv=iv))
     return encrypted_data.decode('utf-8')