Onyx
Onyx

Reputation: 9

How can I inject user-specific data (like a public key) into a pre-built Go binary without needing Go installed?

I am working on a Go application that encrypts sensitive files using a public key. The goal of my project is to create a customizable encryption tool that allows users to generate an executable tailored to their needs. The idea is that the user will input their own public key, and the tool will produce a unique executable, which they can then use to securely encrypt their files.

The challenge is that I cannot assume the target machine has Go installed for me to compile the code locally. Additionally, I would like to ensure the solution is portable, meaning the executable should be able to run on any machine without requiring Go setup.

How can I inject a user-specific public key into a pre-built Go binary after it’s been compiled? Or are there better solutions that I could not think of?

Upvotes: 0

Views: 21

Answers (1)

Gene
Gene

Reputation: 544

This is an interesting question and, without manually modifying the compiled code, I'm not sure you can. But, since you asked for alternatives, there are a number of options:

  • An encrypted data file that stores the key (you'll need to secure this)
  • A local data store with encryption (need a data store installed in the app environment somewhere)
  • A cloud key service accessible for each instance (AWS provides this)
  • A K8s key store (if the apps are running in that environment)

You could simply read their public key and store it in a local file or something for use since it is "public" (i.e freely available and known).

Upvotes: 1

Related Questions