// DecodeKey decodes a key from s and returns it. The key can be in
// hexadecimal, standard base64, or URL-safe base64.
480496
func DecodeKey(s string) (*Key, error) {
	var b []byte
	var err error
	if s == "" {
		return nil, errors.New("empty key")
	}
	if len(s) == hex.EncodedLen(len(Key{})) {
		b, err = hex.DecodeString(s)
	} else {
		b, err = base64.StdEncoding.DecodeString(s)
		if err != nil {
			b, err = base64.URLEncoding.DecodeString(s)
		}
	}
	if err != nil {
		return nil, err
	}
	if len(b) != len(Key{}) {
		return nil, errKeyLen
	}
	k := new(Key)
	copy(k[:], b)
	return k, nil
}
652791
func UnmarshalKey(key string, rawVal interface{}, opts ...DecoderConfigOption) error {
	return v.UnmarshalKey(key, rawVal, opts...)
}
260572
func (e *Encoding) Decode(dst, src []byte) (int, error) {
	if len(src)%2 == 1 {
		return 0, ErrLength
	}

	for i := 0; i < len(src)/2; i++ {
		a, ok := e.fromHexChar(src[i*2])
		if !ok {
			return 0, InvalidByteError(src[i*2])
		}
		b, ok := e.fromHexChar(src[i*2+1])
		if !ok {
			return 0, InvalidByteError(src[i*2+1])
		}
		dst[i] = (a << 4) | b
	}

	return len(src) / 2, nil
}
1144222
func hexToKeybytes(hex []byte) []byte {
	if hasTerm(hex) {
		hex = hex[:len(hex)-1]
	}
	if len(hex)&1 != 0 {
		panic("can't convert hex key of odd length")
	}
	key := make([]byte, len(hex)/2)
	decodeNibbles(hex, key)
	return key
}
66128
func decodeDateInt(buf []byte) (days int) {
	days = int(buf[0]) + int(buf[1])*256 + int(buf[2])*256*256
	return
}
1084435
func (mock *Mock) Decode(data []byte) ([]*FileDataEntry, error) {
	items := mock.getReturnValues("Decode")
	if len(items) == 1 {
		switch typed := items[0].(type) {
		case []*FileDataEntry:
			return typed, nil
		case error:
			return []*FileDataEntry{}, typed
		}
	} else if len(items) == 2 {
		return items[0].([]*FileDataEntry), items[1].(error)
	}
	return []*FileDataEntry{}, nil
}
901128
func Decode(str string) []byte {
    var (
        out bytes.Buffer
        bits []string = strings.Split(str, "-")
    )
    
    for i := 0; i < len(bits); i++ {
        var x uint16 = consd[bits[i][0]] +
                (vowsd[bits[i][1]] <<  4) +
                (consd[bits[i][2]] <<  6) +
                (vowsd[bits[i][3]] << 10) + 
                (consd[bits[i][4]] << 12)
        
        out.WriteByte(byte(x >> 8))
        out.WriteByte(byte(x))
    }
    
    return out.Bytes()
}
1069301
func Decode(m []byte) (context.Context, error) {
	if len(m) == 0 {
		// TODO maybe return an error
		return nil, nil
	}
	mp := make(map[string]interface{}, 0)
	err := json.Unmarshal(m, &mp)
	if err != nil {
		return nil, err
	}
	return FromMap(mp), nil
}
315683
func (j *jsonEncoder) Decode(data []byte, v interface{}) error {
	return json.Unmarshal(data, v)
}
1068874
func (c *ConfigLookup) UnmarshalKey(key string, rawVal interface{}, opts ...UnmarshalOption) error {
	value, ok := c.Lookup(key)
	if !ok {
		return nil
	}

	//mandatory hook func
	var unmarshalHooks []mapstructure.DecodeHookFunc
	unmarshalHooks = append(unmarshalHooks, mapstructure.StringToTimeDurationHookFunc())

	//check for opts
	unmarshalOptions := unmarshalOpts{}
	for _, param := range opts {
		param(&unmarshalOptions)
	}

	//compose multiple hook funcs to one if found in opts
	hookFn := mapstructure.ComposeDecodeHookFunc(append(unmarshalHooks, unmarshalOptions.hooks...)...)

	//build decoder
	decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
		DecodeHook: hookFn,
		Result:     rawVal,
	})
	if err != nil {
		return err
	}

	//decode
	return decoder.Decode(value)
}
595476
func (it *Iterator) BufKey(b []byte) []byte {
	k := it.RawKey()
	if k == nil {
		return nil
	}
	if b == nil {
		b = []byte{}
	}

	b = b[0:0]
	return append(b, k...)
}
1117263
func (c *cipher) ekskey(data []byte, key []byte) {
	var word uint
	koff := 0
	doff := 0
	lr := []uint{0, 0}
	plen := len(c.P)
	slen := len(c.S)

	for i := 0; i < plen; i++ {
		word, koff = streamtoword(key, koff)
		c.P[i] = c.P[i] ^ word
	}

	for i := 0; i < plen; i += 2 {
		word, doff = streamtoword(data, doff)
		lr[0] ^= word
		word, doff = streamtoword(data, doff)
		lr[1] ^= word
		c.encipher(lr, 0)
		c.P[i] = lr[0]
		c.P[i+1] = lr[1]
	}

	for i := 0; i < slen; i += 2 {
		word, doff = streamtoword(data, doff)
		lr[0] ^= word
		word, doff = streamtoword(data, doff)
		lr[1] ^= word
		c.encipher(lr, 0)
		c.S[i] = lr[0]
		c.S[i+1] = lr[1]
	}
}
499344
func (c *CipherSeed) decode(r io.Reader) error {
	err := binary.Read(r, binary.BigEndian, &c.InternalVersion)
	if err != nil {
		return err
	}

	if err := binary.Read(r, binary.BigEndian, &c.Birthday); err != nil {
		return err
	}

	if _, err := io.ReadFull(r, c.Entropy[:]); err != nil {
		return err
	}

	return nil
}
292332
func (e *encoding) decode(s string) uint64 {
	x := uint64(0)
	for i := 0; i < len(s); i++ {
		x = (x << 5) | uint64(e.dec[s[i]])
	}
	return x
}
1201943
func Decode(s string) uint64 {
	res := uint64(0)
	l := len(s) - 1
	for idx := range s {
		c := s[l-idx]
		res += uint64(index[c]) * uint64(math.Pow(36, float64(idx)))
	}
	return res
}
63435
func ParseNwkSKey(input string) (key NwkSKey, err error) {
	aes128key, err := ParseAES128Key(input)
	if err != nil {
		return
	}
	key = NwkSKey(aes128key)
	return
}
700925
func Decode(token string) int {
  number := 0
  idx    := 0.0
  chars  := []byte(alphabet)

  charsLength := float64(len(chars))
  tokenLength := float64(len(token))

  for _, c := range []byte(token) {
    power := tokenLength - (idx + 1)
    index := bytes.IndexByte(chars, c)
    number += index * int(math.Pow(charsLength, power))
    idx++
  }

  return number
}