Skip to content

Instantly share code, notes, and snippets.

@hUwUtao
Last active May 12, 2024 19:02
Show Gist options
  • Save hUwUtao/042d419ef32a7828dd5155fdefe06e7c to your computer and use it in GitHub Desktop.
Save hUwUtao/042d419ef32a7828dd5155fdefe06e7c to your computer and use it in GitHub Desktop.
A tool to quickly encrypt stuff without yapping about command line. Result a self-extract and pipeable. Still require user-typed password :))

Run

[ENVIRONMENT AS FLAGS] sh encit.sh FILE

because lazily hardcoded, dont go out of bound

Flags

pls figure this out i dont have time

  • COMPRESSION: anything that have -d
  • ALGORITHM: openssl enc -list (firsh dash included)

Update

  • Don't compress urandom. +80 bytes bench for a 30 byte test. still the result worth like 1.15kb
  • Enforce saving with PLSAVE=true flag
#!/usr/bin/bash
COMPRESSION=${COMPRESSION:-"gzip"}
ALGORITHM=${ALGORITHM:-"-aes-256-cbc"}
OUTC=$([ "$PLSAVE" == true ]; printf ">\"$1\"")
OUTF="$1.sh"
echo $OUTC $OUTF
rm -f "$OUTF"
touch "$OUTF"
echo "#!/bin/sh
sed -e 1,/^exit$/d \"\$0\"|openssl enc -$ALGORITHM -pbkdf2 -d|tail -c +1025|$COMPRESSION -d$OUTC
exit" >> "$OUTF"
sh -c "head -c 1024 /dev/urandom
# couldnt be much worse
cat \"$1\" | $COMPRESSION" | openssl enc $ALGORITHM -pbkdf2 -e >> "$OUTF"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment