// KEKS -- Go KEKS codec implementation
// Copyright (C) 2024-2025 Sergey Matveev <stargrave@stargrave.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program.  If not, see <http://www.gnu.org/licenses/>.

package keks

import (
	crand "crypto/rand"
	"io"
	"math/rand/v2"
)

var (
	PRNG *rand.ChaCha8
	Junk []byte
)

func init() {
	var seed [32]byte
	crand.Read(seed[:])
	PRNG = rand.NewChaCha8(seed)
	Junk = make([]byte, 1+rand.UintN(7))
	if _, err := io.ReadFull(PRNG, Junk); err != nil {
		panic(err)
	}
}
