func EncodeMeta()

in v3/internal/object_metadata.go [124:144]


func EncodeMeta(reader lengthReader, cryptographicMaterials materials.CryptographicMaterials) (ObjectMetadata, error) {
	iv := base64.StdEncoding.EncodeToString(cryptographicMaterials.IV)
	key := base64.StdEncoding.EncodeToString(cryptographicMaterials.EncryptedKey)

	encodedMatDesc, err := cryptographicMaterials.MaterialDescription.EncodeDescription()
	if err != nil {
		return ObjectMetadata{}, err
	}

	contentLength := reader.GetContentLength()

	return ObjectMetadata{
		CipherKey:             key,
		IV:                    iv,
		MatDesc:               string(encodedMatDesc),
		KeyringAlg:            cryptographicMaterials.KeyringAlgorithm,
		CEKAlg:                cryptographicMaterials.CEKAlgorithm,
		TagLen:                cryptographicMaterials.TagLength,
		UnencryptedContentLen: strconv.FormatInt(contentLength, 10),
	}, nil
}