github.com/hoffie/larasync@v0.0.0-20151025221940-0384d2bddcef/helpers/crypto/hasher_test.go (about)

     1  package crypto
     2  
     3  import (
     4  	. "gopkg.in/check.v1"
     5  )
     6  
     7  type HasherTests struct {
     8  	hashKey [HashingKeySize]byte
     9  }
    10  
    11  var _ = Suite(&HasherTests{})
    12  
    13  func (t *HasherTests) SetUpTest(c *C) {
    14  	t.hashKey = [HashingKeySize]byte{}
    15  }
    16  
    17  func (t *HasherTests) getHasher() *Hasher {
    18  	return NewHasher(t.hashKey)
    19  }
    20  
    21  func (t *HasherTests) TestHashing(c *C) {
    22  	t.getHasher().Hash([]byte("test"))
    23  }
    24  
    25  func (t *HasherTests) TestDifferntKeys(c *C) {
    26  	testBytes := []byte("test")
    27  	firstCheck := t.getHasher().StringHash(testBytes)
    28  	t.hashKey[0] = 200
    29  	secondCheck := t.getHasher().StringHash(testBytes)
    30  	c.Assert(firstCheck, Not(Equals), secondCheck)
    31  }