go-hexadeca/bytes/encodebyte.go

23 lines
669 B
Go
Raw Normal View History

2023-10-27 20:18:32 +00:00
package hexadecabytes
import (
"sourcecode.social/reiver/go-hexadeca/symbols/byte"
)
// EncodeByte encodes the value of a byte into hexadecimal.
func EncodeByte(value byte, symbolFunc func(byte)byte) (mostSignificant byte, leastSignificant byte) {
mostSignificant = symbolFunc( (0xf0 & value) >> 4 )
leastSignificant = symbolFunc( (0x0f & value) )
return
}
func EncodeByteUsingLowerCaseSymbols(value byte) (mostSignificant byte, leastSignificant byte) {
return EncodeByte(value, bytesymbols.LowerCase)
}
func EncodeByteUsingUpperCaseSymbols(value byte) (mostSignificant byte, leastSignificant byte) {
return EncodeByte(value, bytesymbols.UpperCase)
}