]> Sergey Matveev's repositories - paster.git/blobdiff - main.go
Trivial style fixes
[paster.git] / main.go
diff --git a/main.go b/main.go
index 25e93d4f45ad03d34809e6b1f153b6673b3e6124..17957374a6e4bbf799f3930798b1a6dc7b2f3404 100644 (file)
--- a/main.go
+++ b/main.go
@@ -1,19 +1,17 @@
-/*
-paster -- paste service
-Copyright (C) 2021-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/>.
-*/
+// paster -- paste service
+// Copyright (C) 2021-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
 
@@ -21,7 +19,6 @@ import (
        "bufio"
        "bytes"
        "crypto/rand"
-       "crypto/sha512"
        _ "embed"
        "encoding/base32"
        "encoding/hex"
@@ -32,6 +29,7 @@ import (
        "os"
 
        "go.cypherpunks.ru/netstring/v2"
+       "lukechampine.com/blake3"
 )
 
 const MaxExtLen = 9
@@ -122,7 +120,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 +157,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