Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

Code Block
titleExample for Encryption using Unix Shell
linenumberstrue
result=$(./bin/js7_encrypt.sh --cert=agent.crt --in="secret")
echo "${result}$result"

# encrypts the given secret using an Agent's X.509 certificate
# output includes the symmetric key, initialization vector and encrypted string separated by space

...

Code Block
titleExample for Encryption using Unix Shell
linenumberstrue
result=$(./bin/js7_encrypt.sh --cert=agent.crt --in="secret")
echo "result=${result}new_var=$result" >> $JS7_RETURN_VALUES

# encrypts the given secret using an Agent's X.509 certificate
# output includes the symmetric key, initialization vector and encrypted string separated by spaces
# output is stored to the "resultnew_var" variable (key/value pair) that is made available for later jobs in the workflow

...

Code Block
titleExample for Encryption using Unix Shell
linenumberstrue
echo "secret file" > /tmp/secret.txt
result=$(./bin/js7_encrypt.sh --cert=agent.crt --infile=/tmp/secret.txt --outfile=/tmp/secret.txt.encrypted)
echo "${result}$result"

# encrypts the given file using an Agent's X.509 certificate and creates an encrypted output file
# output includes the symmetric key, initialization vector and path to encrypted file separated by spaces

...

Code Block
titleExample for Decryption using Unix Shell
linenumberstrue
# assumes that previous encryption created the "result" variable
# result=$(./bin/js7_encrypt.sh --cert=agent.crt --in="secret")

secret=$(./bin/js7_decrypt.sh \
    --key=agent.key \
    --key-password="jobscheduler" \
    --encrypted-key="$(echo "${result}$result" | cut -d' ' -f 1)" \
    --iv="$(echo "${result}$result" | cut -d' ' -f 2)" \
    --in="$(echo "${result}$result" | cut -d' ' -f 3)")
echo "${secret}"

# decrypts the given encrypted secret using an Agent's private key and passphrace
# initialization vector, encrypted symmetric key and encrypted secret are returned during encryption
# output includes the decrypted secret

...

Code Block
titleExample for Decryption using Unix Shell
linenumberstrue
# assumes that previous encryption created the "result" variable
# result=$(./bin/js7_encrypt.sh --cert=agent.crt --infile=/tmp/secret.txt --outfile=/tmp/secret.txt.encrypted)

./bin/js7_decrypt.sh \
    --key=agent.key \
    --key-password="jobscheduler" \
    --encrypted-key="$(echo "${result}" | cut -d' ' -f 1)" \
    --iv="$(echo "${result}" | cut -d' ' -f 2)" \
    --infile=$(echo "${result}" | cut -d' ' -f 3) \
    --outfile=/tmp/secret.txt.decrypted
cat /tmp/secret.txt.decrypted

# decrypts the given encrypted file using an Agent's private key and passphrase
# creates the decrypted output file

...