Skip to content

Instantly share code, notes, and snippets.

@Darryl-G
Darryl-G / PoSh_OpenSSL_AES
Last active February 8, 2024 00:45 — forked from mendel129/PoSh_OpenSSL_AES
Powershell Basic Routines for Encrypt and Decrypt AES 256 CBC using OpenSSL EVP
#PowerShell to create an gibberishaes(and openssl) compatible aes string with salt
#Salted__8bitsalt/aesstring
#thanks for .netcode -> http://stackoverflow.com/questions/5452422/openssl-using-only-net-classes
#
# This outputs the same ciphertext as: echo -n "SomePlainText"|/usr/bin/openssl enc -A -e -aes-256-cbc -a -pass pass:ThePassword
# For decrypt: echo "[cipherText]"|/usr/bin/openssl base64 -d|/usr/bin/openssl enc -A -d -aes-256-cbc -pass pass:ThePassword
function OpenSSLEncrypt($passphrase, $plainText)
{
# generate salt