#!/bin/bash IFS=$'\n' DIR=$(dirname ${1}) FILE=$(basename ${1}) if [ ! -f ${1} ]; then echo "Le fichier '$1' n'existe pas." exit 0 fi if [ -f ${1}.aes ]; then echo "Il existe déjà un fichier chiffré portant le nom '${1}.aes'. Opération annulée." exit 0 fi if [ -f ${DIR}/.${FILE}.aes.key ]; then echo "Il existe déjà un fichier de clé '.${FILE}.aes.key'. Veuillez le déplacer ou le supprimer." exit 0 fi echo "Utilisez votre souris pour générer des données aléatoires :" openssl enc -e -p -nosalt -aes-256-cbc -in ${1} -out ${1}.aes \ -K $(cat /dev/random | od -A n -t x -N 32 -w | tr -d ' ') \ -iv $(cat /dev/random | od -A n -t x -N 16 -w | tr -d ' ') \ | cut -d'=' -f2 \ | openssl rsautl -encrypt -pubin -inkey ~/ssl/chiffrement_pub.key -out ${DIR}/.${FILE}.aes.key \ && (cd ${DIR} ; wipe ${FILE})