]> Sergey Matveev's repositories - paster.git/commitdiff
BLAKE3 v2.1.0
authorSergey Matveev <stargrave@stargrave.org>
Wed, 19 Apr 2023 11:34:34 +0000 (14:34 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 19 Apr 2023 11:34:34 +0000 (14:34 +0300)
doc/examples.texi
doc/features.texi
go.mod
go.sum
main.go

index 1de5e34ed2bebc8f817533cb1ab9843073351ad6..0f1322ae54e136a93dd9e38618695c2491846e18 100644 (file)
@@ -12,14 +12,14 @@ something I want to send
 whatever whenever
 ^D
 http://paster.example.com/4KEOLWCZY5CBVWDNT5TA.txt
-SHA512/2: 28d95ef0e8d6a4f4222d0e7eb2a23777aa99efb0794e535a0f4a55490705438f
+BLAKE3-256: e5f9c87b75b2060895e95b69d8d845fc46f3ec7b89f0641519c930005c694077
 @end example
 
 @item With overriden file extension
 @example
 $ paster webp < some-image.webp
 http://paster.example.com/KO5O7SJTUGBORVGOZBSA.webp
-SHA512/2: 7f53424fe50f1d70fa32763cde31335dc82fd63c975e8ab95f0bb4a6cd94fb1c
+BLAKE3-256: 7f53424fe50f1d70fa32763cde31335dc82fd63c975e8ab95f0bb4a6cd94fb1c
 @end example
 
 @item With file extension taken from the specified path. Daemon is run
@@ -30,7 +30,7 @@ $ paster some-other-image.webp
 http://paster.example.com/O6D2O3N5HPH63ZFIYF4A.webp
 https://paster.example.com/O6D2O3N5HPH63ZFIYF4A.webp
 ftp://paster.example.com/pub/pastes/O6D2O3N5HPH63ZFIYF4A.webp
-SHA512/2: 2ffe10846ec637d29ab9145b98c3699653c01910bb6d9e00e41f7fe02c5882a8
+BLAKE3-256: 2ffe10846ec637d29ab9145b98c3699653c01910bb6d9e00e41f7fe02c5882a8
 @end example
 
 @item
@@ -48,7 +48,7 @@ $ paster < /proc/cpuinfo
 @example
 $ paster path/to/ascii.cast
 http://paster.example.com/ST4LOKGUISMACAAFC4CA.cast
-SHA512/2: 171e39f35b58b39f0bc2f3def59955d6573756374584d5443afa16d31032fdf3
+BLAKE3-256: 171e39f35b58b39f0bc2f3def59955d6573756374584d5443afa16d31032fdf3
 http://paster.example.com/ST4LOKGUISMACAAFC4CA.cast.html
 @end example
 
index ffd0539007e52e39f6e55636516936570daf72a8..338060b02a602368817df5496150235af9d060ca 100644 (file)
@@ -18,7 +18,7 @@
 
 @item Newline is appended for @file{.txt}/@file{.url} pastes, if it is missing
 
-@item SHA512/2 checksum is sent back to you, for integrity checking
+@item BLAKE3-256 checksum is sent back to you, for integrity checking
 
 @item Intended to be run as a @url{https://cr.yp.to/ucspi-tcp.html, UCSPI-TCP}
     service @url{http://cr.yp.to/daemontools.html, daemontools}-like supervisor
diff --git a/go.mod b/go.mod
index 4dbc7c13a1407b4c3ffcdbef9bd7e091ca88e38d..76d5dfb5193ab179910d92ad93bfafa2d2dc183f 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -2,4 +2,12 @@ module go.stargrave.org/paster/v2
 
 go 1.17
 
-require go.cypherpunks.ru/netstring/v2 v2.4.0
+require (
+       go.cypherpunks.ru/netstring/v2 v2.4.0
+       lukechampine.com/blake3 v1.1.7
+)
+
+require (
+       github.com/klauspost/cpuid/v2 v2.2.4 // indirect
+       golang.org/x/sys v0.7.0 // indirect
+)
diff --git a/go.sum b/go.sum
index 504496380f36cf8b8a16120bb537303b9676e2cb..e02e02d42fa8c1ac15b5573e53a7591e7a3cbc7e 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -1,2 +1,10 @@
+github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
+github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk=
+github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
 go.cypherpunks.ru/netstring/v2 v2.4.0 h1:qBOtHJj1hoCUpYkouuTurXl20R1IKnEkh+q7/J0TgZ4=
 go.cypherpunks.ru/netstring/v2 v2.4.0/go.mod h1:6YDx4gW414SmHdvSBMKbHaB2/7w9WZ04NQb7XIUV/pA=
+golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
+golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+lukechampine.com/blake3 v1.1.7 h1:GgRMhmdsuK8+ii6UZFDL8Nb+VyMwadAgcJyfYHxG6n0=
+lukechampine.com/blake3 v1.1.7/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA=
diff --git a/main.go b/main.go
index 25e93d4f45ad03d34809e6b1f153b6673b3e6124..c1bc2712484828c6b1ba80781c0ae2695df1a720 100644 (file)
--- a/main.go
+++ b/main.go
@@ -21,7 +21,6 @@ import (
        "bufio"
        "bytes"
        "crypto/rand"
-       "crypto/sha512"
        _ "embed"
        "encoding/base32"
        "encoding/hex"
@@ -32,6 +31,7 @@ import (
        "os"
 
        "go.cypherpunks.ru/netstring/v2"
+       "lukechampine.com/blake3"
 )
 
 const MaxExtLen = 9
@@ -122,7 +122,7 @@ func main() {
        if err != nil {
                fatal(err.Error())
        }
-       h := sha512.New()
+       h := blake3.New(32, nil)
        bfd := bufio.NewWriter(fd)
        mw := io.MultiWriter(bfd, h)
        buf := make([]byte, 1)
@@ -159,7 +159,7 @@ func main() {
        for _, u := range flag.Args() {
                fmt.Println(u + fn[1:])
        }
-       fmt.Println("SHA512/2:", hex.EncodeToString(h.Sum(nil)[:sha512.Size/2]))
+       fmt.Println("BLAKE3-256:", hex.EncodeToString(h.Sum(nil)))
        if ext == ".cast" && *asciicastPath != "" {
                if err = asciicastHTML(*asciicastPath, fn[1:]); err != nil {
                        goto Failed