credentials

package
v0.0.0-...-ef6ba02 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package credentials implements necessary functions to cooperate with ActiveSupport::EncryptedConfiguration. See active_support/encrypted_configuration.rb(https://github.com/rails/rails/blob/04df9bc3d120b51447bde54caa56e9237cb8da0e/activesupport/lib/active_support/encrypted_configuration.rb) for the reference implementation.

Index

Constants

View Source
const (
	CredentialsFileContentTemplate = `` /* 246-byte string literal not displayed */

)
View Source
const (
	// MasterKeyLengthBytes is the length of the master key in bytes.
	// AES-128-GCM requires a 16-byte key.
	MasterKeyLengthBytes = 16
)

Variables

View Source
var Base64Encoding = base64.StdEncoding

Functions

func Decrypt

func Decrypt(MasterKey string, EncryptedFileContent string) (DecryptedFileContent []byte, err error)

Decrypt decrypts the encrypted file content using the master key. The master key should be a hex-encoded string of 32 hex characters (16 bytes). The encrypted file content is expected to be in the format: <base64-encoded-content><Separator><base64-encoded-iv><Separator><base64-encoded-tag> The content is encrypted using AES-128-GCM.

func Encrypt

func Encrypt(MasterKey string, RawFileContent []byte) (EncryptedFileContent string, err error)

Encrypt encrypts the raw file content using the master key.

func MarshalSingleString

func MarshalSingleString(source string) ([]byte, error)

MarshalSingleString converts a string into Ruby marshal format.

func NewCredentialsFileContent

func NewCredentialsFileContent() (string, error)

NewCredentialsFileContent generates a credentials.yml example. This function is only used in the TUI.

func RandomMasterKey

func RandomMasterKey() (string, error)

RandomMasterKey generates a random master key.

func SanitizeMasterKey

func SanitizeMasterKey(in string) string

func UnmarshalSingleString

func UnmarshalSingleString(marshalledObject []byte) (string, error)

UnmarshalSingleString extracts a single string from a Ruby marshalled object. The string must be the first item. Everything else is discarded.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL