26 lines
374 B
Go
26 lines
374 B
Go
package crypto
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"lux/types"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type LuxKey struct {
|
|
Type types.LuxType
|
|
Id uuid.UUID
|
|
Key []byte
|
|
}
|
|
|
|
func (key *LuxKey) NewLuxKey(keyType types.LuxType) error {
|
|
key.Type = keyType
|
|
key.Id = uuid.New()
|
|
key.Key = make([]byte, 32)
|
|
|
|
if _, err := rand.Read(key.Key); err != nil {
|
|
return err
|
|
} else {
|
|
return nil
|
|
}
|
|
}
|