StreetCreds

This is a gem that manages encrypted YAML files that can be used to store credentials and stuff you might just not want to leave lying around on your system.

It doesn't use a strong or unique IV or anything like that. It's not top-notch security. It's just a quick-and-dirty way to obfuscate things you might be using locally to enable your code to access resources, short of using a local deployment of a secret manager like Hashicorp Vault.

It uses ruby 2.0 hash-syntax for many of its methods, allowing you to leave some things un-filled and asking for them if it needs them. If you don't want your code being interrupted to ask for a password, provide one programatically.

This is a complete rewrite of StreetCreds 0.1 and is definitely not backwards-compatible. It's barely the same thing.

Usage

Use it like this:

# #convert_on_valid is false by default and will assume you want to encrypt a valid YAML file
#  if it hasn't been encrypted already.
cf = StreetCreds::CredFile.new(filepath: '~/mycreds.yml', convert_on_valid: true)

# Add a cred via code:
cf['github'] = {'username' => 'wwboynton', password: 'xxxxxxxxxxxxxx'}
# Worth noting, all your keys will be recursively symbolized. Hope that's okay.

# #inspect is overridden and will #inspect the internal hash.
#  This will show all values, including passwords and sensitive data!
puts cf.inspect

# Save back to the file. This will always be encrypted.
cf.save

# Decrypt a file in-place
StreetCreds::CredFile.decrypt_existing_file(filepath: '~/mycreds.yml')

# You can encrypt-in-place too, but you could also just use #convert_on_valid
StreetCreds::CredFile.encrypt_existing_file(filepath: '~/mycreds.yml')

License

It's MIT. Do whatever.

Contributing

I guess you can PR if you really want to. I'd probably look at it.