56 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			56 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package nomino_test
 | |
| 
 | |
| import (
 | |
| 	"crypto"
 | |
| 	"crypto/hmac"
 | |
| 	"fmt"
 | |
| 	"hash"
 | |
| 
 | |
| 	"codeberg.org/danjones000/nomino"
 | |
| )
 | |
| 
 | |
| func ExampleSlug() {
 | |
| 	str, _ := nomino.Slug().Make(nomino.WithOriginal("My name is Jimmy"))
 | |
| 	fmt.Println(str)
 | |
| 
 | |
| 	// Output: my-name-is-jimmy.txt
 | |
| }
 | |
| 
 | |
| func ExampleSlug_withLang() {
 | |
| 	str, _ := nomino.Slug("de").
 | |
| 		Make(nomino.WithOriginal("Diese & Dass"))
 | |
| 	fmt.Println(str)
 | |
| 
 | |
| 	// Output: diese-und-dass.txt
 | |
| }
 | |
| 
 | |
| func ExampleHash_mD5() {
 | |
| 	str, _ := nomino.Hash(crypto.MD5).
 | |
| 		Make(nomino.WithOriginal("foobar"))
 | |
| 	fmt.Println(str)
 | |
| 	// Output: 3858f62230ac3c915f300c664312c63f.txt
 | |
| }
 | |
| 
 | |
| func ExampleHash_sHA1() {
 | |
| 	str, _ := nomino.Hash(crypto.SHA1).
 | |
| 		Make(nomino.WithOriginal("foobar"))
 | |
| 	fmt.Println(str)
 | |
| 	// Output: 8843d7f92416211de9ebb963ff4ce28125932878.txt
 | |
| }
 | |
| 
 | |
| func ExampleHash_sHA256() {
 | |
| 	str, _ := nomino.Hash(crypto.SHA256).
 | |
| 		Make(nomino.WithOriginal("foobar"))
 | |
| 	fmt.Println(str)
 | |
| 	// Output: c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2.txt
 | |
| }
 | |
| 
 | |
| func ExampleHashingFunc_hMAC() {
 | |
| 	var hasher nomino.HashingFunc = func() hash.Hash {
 | |
| 		return hmac.New(crypto.SHA1.New, []byte("hello"))
 | |
| 	}
 | |
| 	g := nomino.Hash(hasher)
 | |
| 	str, _ := g.Make(nomino.WithOriginal("foobar"))
 | |
| 	fmt.Println(str)
 | |
| 	// Output: 85f767c284c80a3a59a9635194321d20dd90f31b.txt
 | |
| }
 |