mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 03:18:24 +00:00 
			
		
		
		
	* Initial commit for 2FA support Signed-off-by: Andrew <write@imaginarycode.com> * Add vendored files * Add missing depends * A few clean ups * Added improvements, proper encryption * Better encryption key * Simplify "key" generation * Make 2FA enrollment page more robust * Fix typo * Rename twofa/2FA to TwoFactor * UNIQUE INDEX -> UNIQUE
		
			
				
	
	
		
			20 lines
		
	
	
		
			458 B
		
	
	
	
		
			Go
		
	
	
	
		
			Vendored
		
	
	
	
			
		
		
	
	
			20 lines
		
	
	
		
			458 B
		
	
	
	
		
			Go
		
	
	
	
		
			Vendored
		
	
	
	
| 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'
 | |
| }
 |