Example #1
0
// MarshalText marshalls the secret into its textual representation.
func (s *StrictSecret) MarshalText() (text []byte, err error) {
	return []byte(fmt.Sprintf(
		"%s:%s:%s",
		s.crypter.Name(),
		internal.UnparseDecryptParams(s.decryptParams),
		s.ciphertext,
	)), nil
}
Example #2
0
func encryptSecret(crypter internal.Crypter, plaintext string, encryptParams internal.EncryptParams) (string, error) {
	ciphertext, decryptParams, err := crypter.Encrypt(plaintext, encryptParams)
	if err != nil {
		return "", err
	}
	return fmt.Sprintf(
		"%s:%s:%s",
		crypter.Name(),
		internal.UnparseDecryptParams(decryptParams),
		ciphertext,
	), nil
}