本文整理汇总了Golang中github.com/jddixon/rnglib_go.PRNG.NextDataFile方法的典型用法代码示例。如果您正苦于以下问题:Golang PRNG.NextDataFile方法的具体用法?Golang PRNG.NextDataFile怎么用?Golang PRNG.NextDataFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jddixon/rnglib_go.PRNG
的用法示例。
在下文中一共展示了PRNG.NextDataFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: doTestSHA
func (s *XLSuite) doTestSHA(c *C, rng *xr.PRNG, whichSHA int) {
var hash, fHash []byte
var sHash string
// name guaranteed to be unique
length, pathToFile := rng.NextDataFile("tmp", 1024, 256)
data, err := ioutil.ReadFile(pathToFile)
c.Assert(err, IsNil)
c.Assert(len(data), Equals, length)
parts := strings.Split(pathToFile, "/")
c.Assert(len(parts), Equals, 2)
fileName := parts[1]
switch whichSHA {
case xu.USING_SHA1:
sha := sha1.New()
sha.Write(data)
hash = sha.Sum(nil)
fHash, err = SHA1File(pathToFile)
case xu.USING_SHA2:
sha := sha256.New()
sha.Write(data)
hash = sha.Sum(nil)
fHash, err = SHA2File(pathToFile)
case xu.USING_SHA3:
sha := sha3.New256()
sha.Write(data)
hash = sha.Sum(nil)
fHash, err = SHA3File(pathToFile)
// XXX DEFAULT = ERROR
}
c.Assert(err, IsNil)
c.Assert(bytes.Equal(hash, fHash), Equals, true)
ml, err := CreateMerkleLeafFromFileSystem(pathToFile, fileName, whichSHA)
c.Assert(err, IsNil)
c.Assert(ml.Name(), Equals, fileName)
c.Assert(bytes.Equal(ml.GetHash(), hash), Equals, true)
c.Assert(ml.WhichSHA(), Equals, whichSHA)
// TODO: test ToString
_ = sHash // TODO
}