Giter Site home page Giter Site logo

rclone_crypt_py's Introduction

rclone_crypt_py

English, 简体中文

Python implementation of encryption/decryption for rclone (crypt storage)

Usage

from rclone import Crypt
# Initialize
# Pass in passwd1 and passwd2

# The password here is the password for creating the crypt, not the password in the rclone configuration file
# If passwd2 is not set, the second parameter can be omitted
crypt = Crypt('PvrhK9lOaJMdJO2', 'bjnW66SNkUuV4hX')

# To use passwords directly in the rclone configuration file(obscured password), you should set the passwd_obscured parameter to True.
# crypt = Crypt('SpnX0yEFxpNJjo9bxd3xAlVoXA7F4cr3C0SA-zmfzw', 'ziWH7jKYerB6o5vHnaXAvISTguFD6ZFJFbhT3BlLVQ', True)

# File encryption/decryption
crypt.File.file_decrypt(input_file_path, output_file_path)
crypt.File.file_encrypt(input_file_path, output_file_path)

# File path encryption/decryption
# obfuscate
crypt.Name.obfuscate_encrypt('Hello,Word')
crypt.Name.obfuscate_decrypt('188.Nkrru,cuxj')

#standard
crypt.Name.standard_encrypt('Hello,Word/你好,世界')
crypt.Name.standard_decrypt('tj0ivgsmd9vh4ccfov7f739in0/lb8g1ak1849smj6mlmpv2c5aio')
from rclone import Crypt
crypt = Crypt('PvrhK9lOaJMdJO2', 'bjnW66SNkUuV4hX')

# bytes decryption
with open('test.bin', 'rb') as f:
    f.seek(8) # Skip the fixed file header b'RCLONE\x00\x00'
    init_nonce = f.read(24) # Read the nonce
    f.seek(5 * (1024 * 64 + 16), 1) # Skip 5 data blocks
    input_bytes = f.read(10 * (1024 * 64 + 16)) # Read 10 data blocks
    output_bytes = crypt.File.bytes_decrypt(input_bytes, init_nonce, 5) # Decrypt the data blocks

# bytes encryption
import nacl
with open('test.bin', 'wb') as f:
    f.write(b'RCLONE\x00\x00') # Write the standard header
    init_nonce = nacl.utils.random(24) # Generate a random nonce (24 bits)
    f.write(init_nonce) # Write the nonce
    with open('origin.bin', 'rb') as fl:
        origin_bytes = fl.read(1024 * 64 * 10) # Read 10 data blocks
        i = 0
        while origin_bytes:
            f.write(crypt.File.bytes_encrypt(origin_bytes, init_nonce, i))
            origin_bytes = fl.read(1024 * 64 * 10)
            i = i + 10

rclone_crypt_py's People

Contributors

ftbom avatar

Stargazers

Nicolas Wang avatar Fox On Fire avatar

Watchers

 avatar

rclone_crypt_py's Issues

can this lib encrypt bytes?

I have used bytes_decrypt while downloading encrypted file using its url.

Now, I wanted to upload file and encrypt them on runtime while uploading.

Is it possible to you to add crypt.File.bytes_encrypt ??

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.