]> Sergey Matveev's repositories - uploader.git/blobdiff - main.go
Unify copyright comment format
[uploader.git] / main.go
diff --git a/main.go b/main.go
index fa2c20e320f2665078b4be89184557d027b66551..720ee4f123ff94da11bdecb9c2544807a2995518 100644 (file)
--- a/main.go
+++ b/main.go
@@ -1,19 +1,17 @@
-/*
-uploader -- simplest form file uploader
-Copyright (C) 2018-2023 Sergey Matveev <stargrave@stargrave.org>
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, version 3 of the License.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
+// uploader -- simplest form file uploader
+// Copyright (C) 2018-2024 Sergey Matveev <stargrave@stargrave.org>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, version 3 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 package main
 
@@ -39,8 +37,8 @@ import (
 
        "go.cypherpunks.ru/recfile"
        "go.cypherpunks.ru/tai64n/v2"
-       "golang.org/x/crypto/blake2b"
        "golang.org/x/net/netutil"
+       "lukechampine.com/blake3"
 )
 
 const (
@@ -57,7 +55,7 @@ var (
 Example command line usage:
 <pre>
 $ curl -F file=@somedata.tar.gpg [-F comment="optional comment"] http://.../upload/
-$ b2sum somedata.tar.gpg # to verify BLAKE2b-512 checksum
+$ b3sum somedata.tar.gpg # to verify BLAKE3-256 checksum
 </pre>
 <form enctype="multipart/form-data" action="/upload/" method="post">
 <label for="file">File to upload:</label><br/>
@@ -93,10 +91,6 @@ func upload(w http.ResponseWriter, r *http.Request) {
                log.Println(r.RemoteAddr, "non file form field")
                return
        }
-       h, err := blake2b.New512(nil)
-       if err != nil {
-               panic(err)
-       }
        t := time.Now()
        ts := new(tai64n.TAI64N)
        ts.FromTime(t)
@@ -108,6 +102,7 @@ func upload(w http.ResponseWriter, r *http.Request) {
                return
        }
        fdBuf := bufio.NewWriterSize(fd, WriteBufSize)
+       h := blake3.New(32, nil)
        mw := io.MultiWriter(fdBuf, h)
        n, err := io.Copy(mw, p)
        if err != nil {