Skip to content

Commit

Permalink
Upgrade code
Browse files Browse the repository at this point in the history
  • Loading branch information
sultaniman committed Jun 22, 2024
1 parent 71735a7 commit eb40c99
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 33 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# PWC
![Tests](https://github.com/imanhodjaev/pwc/actions/workflows/run-tests.yml/badge.svg)

![Tests](https://github.com/imanhodjaev/pwc/actions/workflows/run-tests.yml/badge.svg)
[![CodeQL](https://github.com/sultaniman/pwc/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/sultaniman/pwc/actions/workflows/codeql-analysis.yml)

If you need to remember dozens of passwords without having to remember all of them
Expand Down Expand Up @@ -72,5 +73,4 @@ White #ffffff, Gray #c0c0c0, Red #ffc0c0, Green #c0ffc0, Yellow #ffffc0, Blue #c

P.S. it was inspired by https://www.passwordcard.org/en.


<p align="center">✨ 🚀 ✨</p>
5 changes: 3 additions & 2 deletions canvas/canvas.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package canvas

import (
"image"
"strconv"

"github.com/fogleman/gg"
"github.com/sultaniman/pwc/util"
"golang.org/x/image/font"
"image"
"strconv"
)

const (
Expand Down
5 changes: 3 additions & 2 deletions cmd/classic.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package cmd

import (
"fmt"
"os"
"syscall"

"github.com/spf13/cobra"
"github.com/sultaniman/pwc/gen"
"github.com/sultaniman/pwc/util"
"os"
"syscall"
)

var (
Expand Down
1 change: 1 addition & 0 deletions cmd/explain.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"fmt"

"github.com/fatih/color"
goc "github.com/gookit/color"
"github.com/spf13/cobra"
Expand Down
8 changes: 3 additions & 5 deletions cmd/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package cmd

import (
"fmt"
"os"

"github.com/spf13/cobra"
"github.com/sultaniman/pwc/gen"
"github.com/sultaniman/pwc/util"
"io/ioutil"
"os"
)

var passphrase string
Expand Down Expand Up @@ -36,7 +36,7 @@ var restoreCmd = &cobra.Command{
os.Exit(1)
}

encryptedBytes, err := ioutil.ReadFile(encryptedFile)
encryptedBytes, err := os.ReadFile(encryptedFile)
if err != nil {
return err
}
Expand Down Expand Up @@ -73,8 +73,6 @@ var restoreCmd = &cobra.Command{
}

return util.SaveImage(canvas.Context, outputFile)

return nil
},
}

Expand Down
4 changes: 1 addition & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package cmd

import (
"github.com/spf13/cobra"
)
import "github.com/spf13/cobra"

var rootCmd = &cobra.Command{
Use: "cmd",
Expand Down
3 changes: 2 additions & 1 deletion crypto/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
"crypto/sha256"
"encoding/hex"
"fmt"
"golang.org/x/crypto/pbkdf2"
"strings"

"golang.org/x/crypto/pbkdf2"
)

// TODO(thanks): Encryption was adopted from https://gist.github.com/enyachoke/5c60f5eebed693d9b4bacddcad693b47
Expand Down
3 changes: 2 additions & 1 deletion crypto/crypto_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package crypto

import (
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"
)

func TestMessageEncryptDecrypt(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions gen/classic.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package gen

import (
"image"
"strings"

"github.com/sultaniman/pwc/canvas"
"github.com/sultaniman/pwc/crypto"
"github.com/sultaniman/pwc/util"
"image"
"strings"
)

type ClassicCard struct {
Expand Down
3 changes: 2 additions & 1 deletion gen/classic_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package gen

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/sultaniman/pwc/canvas"
"testing"
)

func TestClassicCard_Generate(t *testing.T) {
Expand Down
4 changes: 1 addition & 3 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package main

import (
"github.com/sultaniman/pwc/cmd"
)
import "github.com/sultaniman/pwc/cmd"

func main() {
cmd.Execute()
Expand Down
3 changes: 2 additions & 1 deletion util/image.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package util

import (
"github.com/fogleman/gg"
"path/filepath"
"strings"

"github.com/fogleman/gg"
)

var supportedExtensions = map[string]bool{
Expand Down
6 changes: 1 addition & 5 deletions util/rand.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package util

import (
"math/rand"
"time"
)
import "math/rand"

type RandRange struct {
Min int
Expand All @@ -18,6 +15,5 @@ func NewRandRange(min int, max int) *RandRange {
}

func (rr *RandRange) Next() int {
rand.Seed(time.Now().UnixNano())
return rand.Intn(rr.Max-rr.Min+1) + rr.Min
}
6 changes: 1 addition & 5 deletions util/string.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package util

import (
"math/rand"
"time"
)
import "math/rand"

func Shuffle(inStr string) string {
rand.Seed(time.Now().UnixNano())
inRune := []rune(inStr)
rand.Shuffle(len(inRune), func(i, j int) {
inRune[i], inRune[j] = inRune[j], inRune[i]
Expand Down

0 comments on commit eb40c99

Please sign in to comment.