A simple, pure Ruby replacement for the core String class to help prevent leaking sensitive information.
Add this line to your application's Gemfile:
gem 'secret_string'And then execute:
$ bundle install
Or install it yourself as:
$ gem install secret_string
SecretString::String simply inherits from String and overrides the #inspect method. That's it.
There are 3 ways to make a secret string:
SecretString.new()SecretString::String.new()String#secret
# 1 & 2
secret = SecretString.new("secret-api-key")
secret = SecretString::String.new(other_string)
# 3
secret = "secret-api-key".secret
secret = other_string.secretConfigure
Requires Rubocop.
The gem is available as open source under the terms of the MIT License.