Skip to content

Commit

Permalink
Use nopadding option
Browse files Browse the repository at this point in the history
  • Loading branch information
hsanjuan committed Mar 5, 2020
1 parent 6443d71 commit 15d1857
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ipfs-8-to-9/migration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ func encode(name string) (string, error) {
return "", fmt.Errorf("key name must be at least one character")
}

encodedName := base32.StdEncoding.EncodeToString([]byte(name))
encoder := base32.StdEncoding.WithPadding(base32.NoPadding)
encodedName := encoder.EncodeToString([]byte(name))
return keyFilenamePrefix + strings.ToLower(encodedName), nil
}

Expand All @@ -47,7 +48,8 @@ func decode(name string) (string, error) {
}

nameWithoutPrefix := strings.ToUpper(name[len(keyFilenamePrefix):])
data, err := base32.StdEncoding.DecodeString(nameWithoutPrefix)
decoder := base32.StdEncoding.WithPadding(base32.NoPadding)
data, err := decoder.DecodeString(nameWithoutPrefix)

return string(data), err
}
Expand Down

0 comments on commit 15d1857

Please sign in to comment.