// We use hex here so we don't need multiple versions
544379
func tlsCipher(cs uint16) string {
	name, present := cipherMapByID[cs]
	if present {
		return name
	}
	return fmt.Sprintf("Unknown [%x]", cs)
}
1275862
func Hex2Bytes(str string) []byte {
	h, _ := hex.DecodeString(str)
	return h
}
5381
func UintToHex(u uint32) CHex {
	hex := U32ToHex(C.uint32_t(u))
	return CHex(hex)
}
504419
func Bytes2Hex(src []byte) []byte {
	dst := make([]byte, 2*len(src))
	hex.Encode(dst, src)

	return dst
}
420280
func (p *parser) scanHex(c int) (rune, error) {

	i := 0

	if p.charsRight() >= c {
		for c > 0 {
			d := hexDigit(p.moveRightGetChar())
			if d < 0 {
				break
			}
			i *= 0x10
			i += d
			c--
		}
	}

	if c > 0 {
		return 0, p.getErr(ErrTooFewHex)
	}

	return rune(i), nil
}
282287
func HexColor() string {
	color := make([]byte, 6)
	hashQuestion := []byte("?#")
	for i := 0; i < 6; i++ {
		color[i] = hashQuestion[rand.Intn(2)]
	}

	return "#" + replaceWithLetters(replaceWithNumbers(string(color)))

	// color := ""
	// for i := 1; i <= 6; i++ {
	// 	color += RandString([]string{"?", "#"})
	// }

	// // Replace # with number
	// color = replaceWithNumbers(color)

	// // Replace ? with letter
	// for strings.Count(color, "?") > 0 {
	// 	color = strings.Replace(color, "?", RandString(letters), 1)
	// }

	// return "#" + color
}
896243
func ParseHex(s string) (Hex, error) {
	var err error
	s, err = uniformHexStrLit(s)
	if err != nil {
		return Hex{}, errors.Trace(err)
	}
	n, err := strconv.ParseInt(s, 0, 64)
	if err != nil {
		return Hex{}, errors.Trace(err)
	}

	return Hex{Value: n}, nil
}
465356
func hexify(arr []byte) string {
	var hexed bytes.Buffer
	for i := 0; i < len(arr); i++ {
		hexed.WriteString(strings.ToUpper(hex.EncodeToString(arr[i : i+1])))
		if i < len(arr)-1 {
			hexed.WriteString(":")
		}
	}
	return hexed.String()
}
518900
func (d *Context) HexEncode(index int) string {
	if s := C.duk_hex_encode(d.duk_context, C.duk_idx_t(index)); s != nil {
		return C.GoString(s)
	}
	return ""
}
307438
func checkIsHex(s string) error {
	switch {
	case s == "":
		return fmt.Errorf("empty hex string")
	case len(s)%2 != 0:
		return fmt.Errorf("uneven number of symbols in the hex string")
	}
	for _, c := range s {
		if !((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f')) {
			return fmt.Errorf("bad lowercase hex string %q, wrong char %c", s, c)
		}
	}
	return nil
}
385296
func char2hex(a rune) int {
	if a >= 48 && a <= 57 { // 0-9
		return int(a) - 48
	} else if a >= 65 && a <= 70 { // A-F
		return int(a) - 55
	} else if a >= 97 && a <= 102 {
		// a-f
		return int(a) - 87
	}
	return -1
}
51277
func extractHexAddresses(s string) ([]string, []uint64) {
	hexStrings := hexNumberRE.FindAllString(s, -1)
	var ids []uint64
	for _, s := range hexStrings {
		if id, err := strconv.ParseUint(s, 0, 64); err == nil {
			ids = append(ids, id)
		} else {
			// Do not expect any parsing failures due to the regexp matching.
			panic("failed to parse hex value:" + s)
		}
	}
	return hexStrings, ids
}
695902
func RandomHex(n int) (string, error) {
	bytes := make([]byte, n)
	if _, err := rand.Read(bytes); err != nil {
		return "", err
	}
	return hex.EncodeToString(bytes), nil
}
508692
func AppendHex(dst []byte, i uint32) []byte {
	if i == 0 {
		return append(dst, '0')
	}
	for j := 7; j >= 0; j-- {
		v := i >> uint(j*4)
		if v > 0 {
			dst = append(dst, HexDigit[v&0xf])
		}
	}
	return dst
}
567511
func GetHex(n int) (string, error) {
	b, err := GetBytes(n)
	if err != nil {
		return "", err
	}

	return hex.EncodeToString(b), nil
}
1258517
func (e Encoder) AppendHex(dst []byte, val []byte) []byte {
	dst = append(dst, byte(majorTypeTags|additionalTypeIntUint16))
	dst = append(dst, byte(additionalTypeTagHexString>>8))
	dst = append(dst, byte(additionalTypeTagHexString&0xff))
	return e.AppendBytes(dst, val)
}
634369
func (p PaperKeyPhrase) Version() (uint8, error) {
	words := p.words()
	if len(words) == 0 {
		return 0, errors.New("empty paper key phrase")
	}
	return wordVersion(words[len(words)-1]), nil
}