func NormalizeKeyword(keyword string) string {
	normalizedKeyword := make([]rune, 0, len(keyword))
	for _, c := range keyword {
		if unicode.IsDigit(c) || unicode.IsLetter(c) {
			normalizedKeyword = append(normalizedKeyword, unicode.ToLower(c))
		}
	}
	return string(normalizedKeyword)
}
NormalizeKeyword normalizes a keyword for adding into the index by converting
it to lower case and keeping only the alphanumeric characters.
package libsearch
import (
	"bytes"
	"crypto/rand"
	"crypto/sha256"
	"encoding/base64"
	"encoding/binary"
	"errors"
	"io/ioutil"
	"math"
	"math/big"
	"os"
	"path/filepath"
	"unicode"
	"github.com/keybase/kbfs/libkbfs"
	sserver1 "github.com/keybase/search/protocol/sserver"
	"golang.org/x/crypto/nacl/secretbox"
)
func GenerateSalts(numKeys, lenSalt int) (salts [][]byte, err error) {
	salts = make([][]byte, numKeys)
	for i := 0; i < numKeys; i++ {
		salts[i] = make([]byte, lenSalt)
		_, err = rand.Read(salts[i])
		if err != nil {
			return
		}
	}
	return
}
func RandUint64n(n uint64) (uint64, error) {
	i := new(big.Int)
	i.SetUint64(n)
	num, err := rand.Int(rand.Reader, i)
	return num.Uint64(), err
}
func GetNumLeadingZeroes(num uint64) uint {
	numZeroes := uint64(64)
	x := num
	var y uint64
	y = x >> 32
	if y != 0 {
		numZeroes -= 32
		x = y
	}
	y = x >> 16
	if y != 0 {
		numZeroes -= 16
		x = y
	}
	y = x >> 8
	if y != 0 {
		numZeroes -= 8
		x = y
	}
	y = x >> 4
	if y != 0 {
		numZeroes -= 4
		x = y
	}
	y = x >> 2
	if y != 0 {
		numZeroes -= 2
		x = y
	}
	y = x >> 1
	if y != 0 {
		numZeroes -= 2
	} else {
		numZeroes -= x
	}
	return uint(numZeroes)
}
func BuildMaskWithLeadingZeroes(numZeroes uint) uint64 {
	return (^uint64(0)) >> numZeroes
}
func RandUint64() (uint64, error) {
	i := new(big.Int)
	i.SetUint64(math.MaxUint64)
	i.Add(big.NewInt(1), i)
	num, err := rand.Int(rand.Reader, i)
	return num.Uint64(), err
}
func XorBytes(one, two []byte, len int) []byte {
	result := make([]byte, len)
	for i := 0; i < len; i++ {
		result[i] = one[i] ^ two[i]
	}
	return result
}
func readInt(input []byte) (int, error) {
	num, numBytes := binary.Varint(input)
	if numBytes <= 0 {
		return 0, errors.New("cannot read the int")
	}
	return int(num), nil
}
func WriteFileAtomic(pathname string, content []byte) error {
	tmpFile, err := ioutil.TempFile(filepath.Dir(pathname), "tmpFile")
	if err != nil {
		return err
	}
	defer os.Remove(tmpFile.Name())
	err = ioutil.WriteFile(tmpFile.Name(), content, 0666)
	if err != nil {
		return err
	}
	err = os.Rename(tmpFile.Name(), pathname)
	return err
}