Data Warehousing and Data integration

SFTP implementation question

More
2 years 3 months ago #23633 by admin
Replied by admin on topic SFTP implementation question
Sorry Kenny no much progress was made unfortunately,

We have been very busy fixing bugs and extending the functionality of our software.

This month we have had eight releases already.  

Mike
ETL Architect
The following user(s) said Thank You: prashant

Please Log in or Create an account to join the conversation.

More
2 years 3 months ago #23639 by Kennyc
Replied by Kennyc on topic SFTP implementation question
Hi Mike,

Appreicated your great effort and looking for the final solution.

Best regards,
Kenny

 

Please Log in or Create an account to join the conversation.

More
2 years 3 months ago #23643 by Peter.Jonson
I had another look

I thing what we need to do here is to separate encryption data transfer and description.

Our software can transfer the data using SFTP but encryption and description are limited to PGP via Gpg4win

In my opinion the best way to tackle the challenge is to write the python script (With ChatGpt help)

Here is a basic example which  performs 3 first steps

from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import padding
from cryptography.hazmat.primitives import hashes
import os

def generate_nonce():
    return os.urandom(32)

def generate_iv():
    return os.urandom(16)

def pad_data(data):
    padder = padding.PKCS7(128).padder()
    padded_data = padder.update(data)
    padded_data += padder.finalize()
    return padded_data

def encrypt_file(input_file, output_file, key, iv):
    with open(input_file, 'rb') as f:
        data = f.read()
    data = pad_data(data)
    cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=default_backend())
    encryptor = cipher.encryptor()
    encrypted_data = encryptor.update(data) + encryptor.finalize()
    with open(output_file, 'wb') as f:
        f.write(encrypted_data)

def main():
    input_file = input("Enter the path of the file to encrypt: ")
    output_file = input_file + '.enc'
    
    nonce = generate_nonce()
    iv = generate_iv()
    
    key = nonce[:32]
    
    encrypt_file(input_file, output_file, key, iv)
    
    print("File encrypted successfully.")

if __name__ == "__main__":
    main()

This script first generates a 32-byte nonce (which acts as the symmetric key) and a 16-byte IV. It then reads the data from the input file, pads it using PKCS7 padding, encrypts it using AES-256 in CBC mode with the provided nonce and IV, and finally writes the encrypted data to a new file with the ".enc" extension.

The script might have some errors (I do not pretend to be an encryption or python expert)

Please accept our apologies for the delay and confusion    
 

Peter Jonson
ETL Developer

Please Log in or Create an account to join the conversation.

More
2 years 3 months ago #23660 by Kennyc
Replied by Kennyc on topic SFTP implementation question
Hi Peter,

Thanks for your python script solution and I will try this way. Seems using codeless way for complex requirements is case by case.

Best regards,

Kenny 

 
The following user(s) said Thank You: Peter.Jonson

Please Log in or Create an account to join the conversation.

Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Read more
Marketing
Set of techniques which have for object the commercial strategy and in particular the market study.
Google
Accept
Decline
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Google Analytics
Accept
Decline
Functional
Tools used to give you more features when navigating on the website, this can include social sharing.
Advertisement
If you accept, the ads on the page will be adapted to your preferences.
Google Ad
Accept
Decline
Save