github.com/gitbundle/modules@v0.0.0-20231025071548-85b91c5c3b01/util/hash_test.go (about)

     1  // Copyright 2023 The GitBundle Inc. All rights reserved.
     2  // Copyright 2017 The Gitea Authors. All rights reserved.
     3  // Use of this source code is governed by a MIT-style
     4  // license that can be found in the LICENSE file.
     5  
     6  package util
     7  
     8  import (
     9  	"fmt"
    10  	"testing"
    11  )
    12  
    13  func Test_GenerateHashString(t *testing.T) {
    14  	salt, err := CryptoRandomString(32)
    15  	if err != nil {
    16  		t.Error(err)
    17  	}
    18  	token := GenerateRandomString()
    19  	hashedString := GenerateHashString(token, salt)
    20  	fmt.Println(hashedString, len(hashedString))
    21  	if len(hashedString) > 255 {
    22  		t.Error("too long hash string")
    23  	}
    24  }