mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-11-03 20:22:25 -06:00 
			
		
		
		
	* [feature] add TOTP two-factor authentication (2FA) * use byteutil.S2B to avoid allocations when comparing + generating password hashes * don't bother with string conversion for consts * use io.ReadFull * use MustGenerateSecret for backup codes * rename util functions
		
			
				
	
	
		
			19 lines
		
	
	
	
		
			458 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			19 lines
		
	
	
	
		
			458 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package utils
 | 
						|
 | 
						|
// RuneToInt converts a rune between '0' and '9' to an integer between 0 and 9
 | 
						|
// If the rune is outside of this range -1 is returned.
 | 
						|
func RuneToInt(r rune) int {
 | 
						|
	if r >= '0' && r <= '9' {
 | 
						|
		return int(r - '0')
 | 
						|
	}
 | 
						|
	return -1
 | 
						|
}
 | 
						|
 | 
						|
// IntToRune converts a digit 0 - 9 to the rune '0' - '9'. If the given int is outside
 | 
						|
// of this range 'F' is returned!
 | 
						|
func IntToRune(i int) rune {
 | 
						|
	if i >= 0 && i <= 9 {
 | 
						|
		return rune(i + '0')
 | 
						|
	}
 | 
						|
	return 'F'
 | 
						|
}
 |