Skip to content

Commit

Permalink
use raw base32 encoding
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Jeromy <[email protected]>
  • Loading branch information
whyrusleeping committed Jun 27, 2016
1 parent 6950edd commit 9861e74
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions blocks/key/key.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package key

import (
"encoding/base32"
"encoding/json"
"fmt"

b58 "gx/ipfs/QmT8rehPR3F6bmwL6zjUN8XpiDBFFpMP2myPdC6ApsWfJf/go-base58"
mh "gx/ipfs/QmYf7ng2hG5XBtJA3tN34DQ2GUN5HNksEw1rLDkmr6vGku/go-multihash"
ds "gx/ipfs/QmZ6A6P6AMo8SR3jXAwzTuSU6B9R2Y4eqW2yW9VvfUayDN/go-datastore"
base32 "gx/ipfs/Qmb1DA2A9LS2wR4FFweB4uEDomFsdmnw1VLawLE1yQzudj/base32"
)

// Key is a string representation of multihash for use with maps.
Expand Down Expand Up @@ -39,7 +39,7 @@ func B58KeyEncode(k Key) string {

// DsKey returns a Datastore key
func (k Key) DsKey() ds.Key {
return ds.NewKey(base32.StdEncoding.EncodeToString([]byte(k)))
return ds.NewKey(base32.RawStdEncoding.EncodeToString([]byte(k)))
}

// UnmarshalJSON returns a JSON-encoded Key (string)
Expand Down Expand Up @@ -70,7 +70,7 @@ func (k *Key) Loggable() map[string]interface{} {

// KeyFromDsKey returns a Datastore key
func KeyFromDsKey(dsk ds.Key) (Key, error) {
dec, err := base32.StdEncoding.DecodeString(dsk.String()[1:])
dec, err := base32.RawStdEncoding.DecodeString(dsk.String()[1:])
if err != nil {
return "", err
}
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@
"hash": "QmQdnfvZQuhdT93LNc5bos52wAmdr3G2p6G8teLJMEN32P",
"name": "go-libp2p-peerstore",
"version": "1.1.2"
},
{
"author": "whyrusleeping",
"hash": "Qmb1DA2A9LS2wR4FFweB4uEDomFsdmnw1VLawLE1yQzudj",
"name": "base32",
"version": "0.0.0"
}
],
"gxVersion": "0.4.0",
Expand Down

0 comments on commit 9861e74

Please sign in to comment.