encryption - How to encrypt particular values in a property file using openssl or gpg -


i wanted know how can go encrypting particular values in properties file using openssl or gpg.

most of examples seem consist of below have seen seem encrypt entire file. wanted use encrypt stored passwords.

to encrypt

openssl enc -aes-256-cbc -in un_encrypted.data -out encrypted.data 

to decrypt

openssl enc -d -aes-256-cbc -in encrypted.data -out un_encrypted.data 

you can use openssl encrypt string want:

$ echo 12345678901 | openssl enc -e -base64 -aes-256-cbc -k mysecretpassword u2fsdgvkx18z9p14y9xrhddrbroejfikdlqxqmgfkag= 

in case use bash script this:

encrypted=`grep "the.name.of.my.property" myfile.properties|cut -d'=' -f2|openssl enc -e -base64 -aes-256-cbc -k mysecretpassword` sed "/the.name.of.my.property=/ s/=.*/=$encrypted/" myfile.properties > newfile.properties 

this produce new file named newfile.properties encrypted field.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -