Andrey Smirnov 050d34275a chore: integrate importvet
This integrates [importvet](https://github.com/talos-systems/importvet)
into `lint` target.

First rule file was added for public packages `pkg/` which shouldn't
depend on other parts of Talos tree (except for the API definitions).

Only one change: `internal/cis` was moved under single user -
`pkg/config/internal/cis` to satisfy the rules.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-08-11 13:19:15 -07:00

23 lines
574 B
Go

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package cis
import (
"crypto/rand"
"encoding/base64"
)
// CreateEncryptionToken generates an encryption token to be used for secrets.
func CreateEncryptionToken() (string, error) {
encryptionKey := make([]byte, 32)
if _, err := rand.Read(encryptionKey); err != nil {
return "", err
}
str := base64.StdEncoding.EncodeToString(encryptionKey)
return str, nil
}