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)
| 15 | return nil, err |
| 16 | } |
| 17 | return cipher.NewGCM(block) |
| 18 | } |
| 19 | |
| 20 | func 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 |