mirror of
				https://github.com/MHSanaei/3x-ui.git
				synced 2025-10-30 20:02:51 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			15 lines
		
	
	
	
		
			372 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			15 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
 | |
| }
 | 
