Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions ADconnection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2480,27 +2480,32 @@ exit
fi
exit
}
################################## encrypt pwd ###############################
Enkla svaret är ja. men det beror på hur man vill använda det. har en grej jag byggde för 6 år sen..

################################## encrypt pwd ###############################
encrypt(){
echo "This will create 3 files public key, private key and encrypted file"
echo "make sure to store private file"
sudo openssl genrsa -out private_key.pem 2048
sudo openssl rsa -in private_key.pem -out public_key.pem -outform PEM -pubout
echo "Please type password to encrypt"
stty -echo
read pass
echo "$pass" > encryptpwd.txt
stty echo
if [ -z "$pass" ]
then
echo "passwd is empty"
exit
else
sudo openssl pkeyutl -encrypt -inkey public_key.pem -pubin -in encryptpwd.txt -out encrypted.dat
sudo rm -rf encryptpwd.txt
ls
fi
exit
echo "This will create 3 files: public key, private key, and encrypted file."
echo "Make sure to store the private key file securely."
sudo openssl genrsa -out private_key.pem 2048
sudo openssl rsa -in private_key.pem -out public_key.pem -outform PEM -pubout

echo "Please type the password to encrypt:"
stty -echo
read pass
stty echo

if [ -z "$pass" ]; then
echo "Password is empty"
exit 1
else
echo -n "$pass" | sudo openssl pkeyutl -encrypt -inkey public_key.pem -pubin -out encrypted.dat
pass=""

echo "Encryption complete. Files created:"
ls
fi
exit
}
################################## info ##################################
readmes(){
Expand Down