I'm using MacOS/10.13
My code on terminal:
echo -n this | openssl enc -aes-128-cbc -K 0 -iv 0 -base64
c code:
int main(){
system("echo -n this | openssl enc -aes-128-cbc -K 0 -iv 0 -base64");
}
Running ScreenShot


The echo command has the problem that its behavior is not portable between different shells or environments. It is better to use printf instead, which is portable. In your case, replace the echo -n statement with printf, resulting in the following code:
#include <stdlib.h>
int main() {
system("printf this | openssl enc -aes-128-cbc -K 0 -iv 0 -base64");
}
Building and running:
$ gcc test.c -o test
$ ./test
gc8X3os/mFxDE73AebmweQ==
as desired.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With