github.com/linapex/ethereum-dpos-chinese@v0.0.0-20190316121959-b78b3a4a1ece/crypto/sha3/xor_generic.go (about)

     1  
     2  //<developer>
     3  //    <name>linapex 曹一峰</name>
     4  //    <email>linapex@163.com</email>
     5  //    <wx>superexc</wx>
     6  //    <qqgroup>128148617</qqgroup>
     7  //    <url>https://jsq.ink</url>
     8  //    <role>pku engineer</role>
     9  //    <date>2019-03-16 12:09:37</date>
    10  //</624342628678242304>
    11  
    12  //版权所有2015 The Go作者。版权所有。
    13  //此源代码的使用受BSD样式的控制
    14  //可以在许可文件中找到的许可证。
    15  
    16  package sha3
    17  
    18  import "encoding/binary"
    19  
    20  //xoringenericxor将buf中的字节转换为状态;它
    21  //makes no non-portable assumptions about memory layout
    22  //或对齐。
    23  func xorInGeneric(d *state, buf []byte) {
    24  	n := len(buf) / 8
    25  
    26  	for i := 0; i < n; i++ {
    27  		a := binary.LittleEndian.Uint64(buf)
    28  		d.a[i] ^= a
    29  		buf = buf[8:]
    30  	}
    31  }
    32  
    33  //copyoutgeneric将ulint64复制到字节缓冲区。
    34  func copyOutGeneric(d *state, b []byte) {
    35  	for i := 0; len(b) >= 8; i++ {
    36  		binary.LittleEndian.PutUint64(b, d.a[i])
    37  		b = b[8:]
    38  	}
    39  }
    40