2025-03-14 19:50:24 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								package nomino_test
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import (
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-15 20:09:38 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									"crypto"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									"crypto/hmac"
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-14 19:50:24 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									"fmt"
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-15 20:09:38 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									"hash"
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-14 19:50:24 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									"codeberg.org/danjones000/nomino"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								func ExampleSlug() {
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-15 20:09:38 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									str, _ := nomino.Slug().Make(nomino.WithOriginal("My name is Jimmy"))
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-14 19:50:24 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									fmt.Println(str)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// Output: my-name-is-jimmy.txt
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								func ExampleSlug_withLang() {
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-15 20:09:38 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									str, _ := nomino.Slug("de").
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										Make(nomino.WithOriginal("Diese & Dass"))
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-14 19:50:24 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									fmt.Println(str)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// Output: diese-und-dass.txt
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								func ExampleHash_mD5() {
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-15 20:09:38 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									str, _ := nomino.Hash(crypto.MD5).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										Make(nomino.WithOriginal("foobar"))
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-14 19:50:24 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									fmt.Println(str)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// Output: 3858f62230ac3c915f300c664312c63f.txt
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								func ExampleHash_sHA1() {
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-15 20:09:38 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									str, _ := nomino.Hash(crypto.SHA1).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										Make(nomino.WithOriginal("foobar"))
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-14 19:50:24 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									fmt.Println(str)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// Output: 8843d7f92416211de9ebb963ff4ce28125932878.txt
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								func ExampleHash_sHA256() {
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-15 20:09:38 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									str, _ := nomino.Hash(crypto.SHA256).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										Make(nomino.WithOriginal("foobar"))
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-14 19:50:24 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									fmt.Println(str)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// Output: c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2.txt
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-15 20:09:38 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								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
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |