Secure data scrambler

.sh
appliance

Famous example rewritten in more secure way by passing random password using process substitution

function scramble {
    # Famous example rewritten in more secure way by passing random password using a pipe
    openssl enc -aes-256-ctr -pbkdf2 -nosalt \
        -pass file:<(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64) \
        </dev/zero 2>/dev/null \
    | sudo dd status=progress iflag=fullblock bs=8M of=$1 oflag=direct
}

## Usage sample
# for (( i = 3 ; i ; i-- ))
# do
#     scramble /dev/foo
# done

## Other auxiliaries
# sudo dd status=progress iflag=fullblock bs=8M if=/dev/zero of=/dev/foo oflag=direct
# sudo badblocks -b 512 -c 8192 -s -w /dev/foo


Notes