MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / UnixTimePrefixedRandomNonce

Function UnixTimePrefixedRandomNonce

driver/ipfs-synckv/singularity.go:17–24  ·  view source on GitHub ↗

UnixTimePrefixedRandomNonce takes an int for the nonce size and returns a byte slice of length size. A byte slice is created for the nonce and filled with random data from `crypto/rand`, then the first 4 bytes of the nonce are overwritten with LittleEndian encoding of `time.Now().Unix()` The purpose

(size int)

Source from the content-addressed store, hash-verified

15 return nil, err
16 }
17 return cipher.NewGCM(block)
18}
19
20func encrypt(data []byte, key []byte) ([]byte, error) {
21 gcm, err := newGCM(key)
22 if err != nil {
23 return nil, err
24 }
25 nonce := make([]byte, gcm.NonceSize())
26 if _, err := rand.Read(nonce); err != nil {
27 return nil, err

Callers 1

encryptFunction · 0.70

Calls 1

ReadMethod · 0.45

Tested by

no test coverage detected