Skip to content

Instantly share code, notes, and snippets.

@louiscklaw
Created August 5, 2017 03:59
Show Gist options
  • Save louiscklaw/72b757e30b7ef09e13d78b08e4730ed4 to your computer and use it in GitHub Desktop.
Save louiscklaw/72b757e30b7ef09e13d78b08e4730ed4 to your computer and use it in GitHub Desktop.
# pip2 install hashlib pwgen
function ztransfer() {
python2 $argv[0] -c '\
import sys, subprocess, hashlib;\
BLOCKSIZE = 65536;\
hasher = hashlib.sha1();\
sTarget = sys.argv[1];\
sTarget7z = "%s.7z" % sTarget;\
from pwgen import pwgen;\
sUnzipPassword=pwgen(50, 1, symbols=False, capitalize=False);\
cmdCompress = ["7z", "a", sTarget7z, sTarget, "-mx9","-p%s" % sUnzipPassword];\
cmdUploadCurl = ["curl", "--upload-file","./%s" % sTarget7z, "https://transfer.sh/%s" % sTarget7z];\
subprocess.check_output(cmdCompress, stderr=subprocess.STDOUT);\
sShareLink = subprocess.check_output(cmdUploadCurl);\
print "unzip password : \"%s\"" % sUnzipPassword;\
print "ShareLink: \"%s\"" % sShareLink;\
' $argv[1]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment