keys/words/wordcodec.go
func (c *WordCodec) BytesToWords(raw []byte) (words []string, err error) {
	// always add a checksum to the data
	data := c.check.AddECC(raw)
	numWords := wordlenFromBytes(len(data))

	n2048 := big.NewInt(2048)
	nData := big.NewInt(0).SetBytes(data)
	nRem := big.NewInt(0)
	// Alternative, use condition "nData.BitLen() > 0"
	// to allow for shorter words when data has leading 0's
	for i := 0; i < numWords; i++ {
		nData.DivMod(nData, n2048, nRem)
		rem := nRem.Int64()
		w := c.words[rem]
		// double-check bank on generation...
		_, err := c.GetIndex(w)
		if err != nil {
			return nil, err
		}
		words = append(words, w)
	}
	return words, nil
}
func (c *WordCodec) BytesToWords(raw []byte) (words []string, err error) {
	// always add a checksum to the data
	data := c.check.AddECC(raw)
	numWords := wordlenFromBytes(len(data))

	n2048 := big.NewInt(2048)
	nData := big.NewInt(0).SetBytes(data)
	nRem := big.NewInt(0)
	// Alternative, use condition "nData.BitLen() > 0"
	// to allow for shorter words when data has leading 0's
	for i := 0; i < numWords; i++ {
		nData.DivMod(nData, n2048, nRem)
		rem := nRem.Int64()
		w := c.words[rem]
		// double-check bank on generation...
		_, err := c.GetIndex(w)
		if err != nil {
			return nil, err
		}
		words = append(words, w)
	}
	return words, nil
}
func ( c * WordCodec ) BytesToWords ( raw [ ] byte ) ( words [ ] string , err error ) { // always add a checksum to the data data := c . check . AddECC ( raw ) numWords := wordlenFromBytes ( len ( data ) ) n2048 := big . NewInt ( 2048 ) nData := big . NewInt ( 0 ) . SetBytes ( data ) nRem := big . NewInt ( 0 ) // Alternative, use condition "nData.BitLen() > 0" // to allow for shorter words when data has leading 0's for i := 0 ; i < numWords ; i ++ { nData . DivMod ( nData , n2048 , nRem ) rem := nRem . Int64 ( ) w := c . words [ rem ] // double-check bank on generation... _ , err := c . GetIndex ( w ) if err != nil { return nil , err } words = append ( words , w ) } return words , nil }
// TODO: add checksum
TODO : add checksum