lib/protocol, vendor: Import luhn code directly

I've changed it incompatibly to fix a correctness bug. Nonetheless, we
should remain incorrect indefinitely.
This commit is contained in:
Jakob Borg
2017-09-20 21:34:32 +02:00
parent 3ee12464b4
commit 2dd9450793
6 changed files with 103 additions and 97 deletions

View File

@@ -10,7 +10,6 @@ import (
"fmt"
"strings"
"github.com/calmh/luhn"
"github.com/syncthing/syncthing/lib/sha256"
)
@@ -158,7 +157,7 @@ func luhnify(s string) (string, error) {
for i := 0; i < 4; i++ {
p := s[i*13 : (i+1)*13]
copy(res[i*(13+1):], p)
l, err := luhn.Base32.Generate(p)
l, err := luhnBase32.generate(p)
if err != nil {
return "", err
}
@@ -176,7 +175,7 @@ func unluhnify(s string) (string, error) {
for i := 0; i < 4; i++ {
p := s[i*(13+1) : (i+1)*(13+1)-1]
copy(res[i*13:], p)
l, err := luhn.Base32.Generate(p)
l, err := luhnBase32.generate(p)
if err != nil {
return "", err
}