Code

What is this?

With this file you can upload, crypt, download files efficiently.

How to use this?

Save this script as a file, like .bashrc_diy, and use ‘source’ to load this.(source .bashrc_diy)

#!/bin/bash
code() {
    if [ $# -eq 0 ]; then
        echo "Usage: code [-d] <script name>"
        echo " -d Download and execute the script with bash"
        return 1
    fi  

    local execute=false
    
    if [ "$1" = "-d" ]; then
        execute=true
        shift
    fi
    
    local script_name="$1"
    local base_url="https://sh.lihanzhang.cn"
    
    if curl -sfO "${base_url}/${script_name}" 2>/dev/null; then
        if [ -f "${script_name}" ]; then
            if [ "$execute" = true ]; then
                bash "${script_name}"
            fi
        fi
    fi
}
transfer() {
    if [ -z "$1" ]; then
            echo Please specify a file
            return 1
    fi
    curl -T "$1" https://u.lihanzhang.cn
    echo
}
enc() {
    if [ "$1" = "-d" ]; then
        shift
        if [ $# -ne 2 ]; then
            echo "Usage: enc -d <input_file> <output_file>"
            return 1
        fi
        openssl enc -d -aes-256-cbc -pbkdf2 -in "$1" -out "$2"
    else
        if [ $# -ne 2 ]; then
            echo "Usage: enc <input_file> <output_file>"
            return 1
        fi
        openssl enc -aes-256-cbc -pbkdf2 -in "$1" -out "$2"
    fi
}
#curl -L sh.lihanzhang.cn/profile -o /root/.local/bin/.bashrc