package cryptoimport (// #nosec)// GuessDataWithHash guesses data from data_with_hash.func ( []byte) []byte {// data_with_hash := SHA1(data) + data + (0-15 random bytes); // such that length be divisible by 16;iflen() <= sha1.Size {// Data length too small.returnnil } := [:sha1.Size]for := 0; < 16; ++ {iflen()- < sha1.Size {// End of slice reached.returnnil } := [sha1.Size : len()-] := sha1.Sum() // #nosecifbytes.Equal([:], ) {// Found.return } }returnnil}func ( int) int { := 16 * ( / 16)if < { += 16 }return}// DataWithHash prepends data with SHA1(data) and 0..15 random bytes so result// length is divisible by 16.//// Use GuessDataWithHash(result) to obtain data.func ( []byte, io.Reader) ([]byte, error) { := make([]byte, paddedLen16(len()+sha1.Size)) := sha1.Sum() // #noseccopy(, [:])copy([sha1.Size:], )if , := io.ReadFull(, [sha1.Size+len():]); != nil {returnnil, }return , nil}
The pages are generated with Goldsv0.6.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.