summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGab <24553253+gabrix73@users.noreply.github.com>2025-12-02 01:16:41 +0100
committerGitHub <noreply@github.com>2025-12-02 01:16:41 +0100
commit9e168486375fc9eb9787eed0ec5451c52dbabe01 (patch)
treec527da6015662ed98338b6ae04e2e1d2dca7af28
parent252c93be7e96d92868e997e9dcd66b2444fec911 (diff)
downloadgensecpass3-9e168486375fc9eb9787eed0ec5451c52dbabe01.tar.gz
gensecpass3-9e168486375fc9eb9787eed0ec5451c52dbabe01.tar.xz
gensecpass3-9e168486375fc9eb9787eed0ec5451c52dbabe01.zip
Update version to 3.1.0 and refactor code
-rw-r--r--gensecpass3.go33
1 files changed, 4 insertions, 29 deletions
diff --git a/gensecpass3.go b/gensecpass3.go
index d02b827..e6fbe3b 100644
--- a/gensecpass3.go
+++ b/gensecpass3.go
@@ -8,6 +8,7 @@ import (
"flag"
"fmt"
"io"
+ "math"
"os"
"strings"
"syscall"
@@ -20,7 +21,7 @@ import (
)
const (
- version = "3.0.1"
+ version = "3.1.0"
minLength = 8
maxLength = 256
defaultLength = 16
@@ -86,13 +87,6 @@ func (es *EntropySource) AddMouseEvent(x, y int, button uint8, timestamp int64)
es.timings = append(es.timings, timestamp)
}
-func (es *EntropySource) AddTimestamp() {
- now := time.Now().UnixNano()
- buf := make([]byte, 8)
- binary.LittleEndian.PutUint64(buf, uint64(now))
- es.data = append(es.data, buf...)
-}
-
func (es *EntropySource) Finalize() {
// Hash finale di tutti i dati + timings
h := sha256.Sum256(es.data)
@@ -333,7 +327,7 @@ func collectMouseEntropy(target int, verbose bool) (*EntropySource, error) {
if lastX > 0 || lastY > 0 {
dx := float64(x - lastX)
dy := float64(y - lastY)
- dist := sqrt(dx*dx + dy*dy)
+ dist := math.Sqrt(dx*dx + dy*dy)
totalDistance += dist
}
@@ -436,18 +430,6 @@ func makeProgressBar(percent float64, width int) string {
return "[" + strings.Repeat("ā–ˆ", filled) + strings.Repeat("ā–‘", empty) + "]"
}
-// Helper: square root approssimato
-func sqrt(x float64) float64 {
- if x <= 0 {
- return 0
- }
- z := x / 2
- for i := 0; i < 10; i++ {
- z = (z + x/z) / 2
- }
- return z
-}
-
// Combina le sorgenti di entropia
func combineEntropy(keyboard, mouse *EntropySource, verbose bool) ([]byte, error) {
if verbose {
@@ -482,19 +464,12 @@ func combineEntropy(keyboard, mouse *EntropySource, verbose bool) ([]byte, error
fmt.Printf("\nšŸ“ˆ Timing Analysis:\n")
fmt.Printf(" Keyboard: %.2f ms avg, %.2f ms variance\n", avgK, stdK)
fmt.Printf(" Mouse: %.2f ms avg, %.2f ms variance\n", avgM, stdM)
- fmt.Printf(" Difference: %.2f ms (higher = better)\n", abs(avgK-avgM))
+ fmt.Printf(" Difference: %.2f ms (higher = better)\n", math.Abs(avgK-avgM))
}
return finalHash[:], nil
}
-func abs(x float64) float64 {
- if x < 0 {
- return -x
- }
- return x
-}
-
// Genera password usando l'entropia combinata
func generatePassword(length int, seed []byte, verbose bool) (*memguard.LockedBuffer, error) {
if length < minLength || length > maxLength {