mirror of
				https://github.com/MHSanaei/3x-ui.git
				synced 2025-10-31 04:12:51 +00:00 
			
		
		
		
	
		
			
	
	
		
			16 lines
		
	
	
	
		
			372 B
		
	
	
	
		
			Go
		
	
	
	
	
	
		
		
			
		
	
	
			16 lines
		
	
	
	
		
			372 B
		
	
	
	
		
			Go
		
	
	
	
	
	
|   | package crypto | ||
|  | 
 | ||
|  | import ( | ||
|  | 	"golang.org/x/crypto/bcrypt" | ||
|  | ) | ||
|  | 
 | ||
|  | func HashPasswordAsBcrypt(password string) (string, error) { | ||
|  | 	hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) | ||
|  | 	return string(hash), err | ||
|  | } | ||
|  | 
 | ||
|  | func CheckPasswordHash(hash, password string) bool { | ||
|  | 	err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)) | ||
|  | 	return err == nil | ||
|  | } |