Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: How to encrypt a file with command line and send it to yopass server? #2506

Open
arbdevml opened this issue Oct 16, 2024 · 0 comments
Open

Comments

@arbdevml
Copy link

Hello, first of all very big thank you for this project.
Example of the command line script encrypting text message:

#!/bin/bash

message=$1;
password=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 20 );

GNUPGHOME=$(mktemp -d /tmp/.gnupgXXXXXX);
export GNUPGHOME;

# encrypt message with $password and replace newlines with "\n";
message=$(echo $message | gpg -a --batch --passphrase $password -c  --cipher-algo AES256 | sed ':a;N;$!ba;s/\n/\\n/g');

payload=$(cat << EOF
{
  "message": "${message}",
  "expiration": 604800 ,
  "one_time": true
}
EOF
);

secret_id=$(curl -k -s -XPOST https://yopass.se/secret -H 'Content-Type: application/json' -d "${payload}" |  jq -r .message);
echo "https://yopass.se/#/s/$secret_id/$password";

The command line encrypt:
echo "text" | gpg -a --batch --passphrase "password" -c --cipher-algo AES256 >./text.gpg && cat ./text.gpg

The command line decrypt:
gpg -d --pinentry-mode loopback --passphrase "password" --batch ./text.gpg 2>/dev/null

What command line alternative of this encrypt function:

encrypt({
          format: 'armored',
          message: await createMessage({
            binary: new Uint8Array(reader.result as ArrayBuffer),
            filename: acceptedFiles[0].name,
          }),
          passwords: pw,
});

How to encrypt a file with command line and send it to yopass server?
Thank you for your answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant