Destruction sécurisée de fichier implémentée
This commit is contained in:
29
pkg/utils/crypto/CryptoSource.go
Normal file
29
pkg/utils/crypto/CryptoSource.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package crypto
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/binary"
|
||||
"log"
|
||||
)
|
||||
|
||||
// Source : https://programming.guide/go/crypto-rand-int.html
|
||||
|
||||
type CryptoSource struct{}
|
||||
|
||||
func NewCryptoSource() *CryptoSource {
|
||||
return &CryptoSource{}
|
||||
}
|
||||
|
||||
func (s CryptoSource) Int63() int64 {
|
||||
return int64(s.Uint64() & ^uint64(1<<63))
|
||||
}
|
||||
|
||||
func (s CryptoSource) Seed(seed int64) {}
|
||||
|
||||
func (s CryptoSource) Uint64() (v uint64) {
|
||||
err := binary.Read(rand.Reader, binary.BigEndian, &v)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
Reference in New Issue
Block a user