Skip to content

Commit

Permalink
Update w7.go
Browse files Browse the repository at this point in the history
  • Loading branch information
simplyYan authored Sep 11, 2023
1 parent dadcad2 commit 75640a5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions w7.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package w7dth
package w7

import (
"crypto/aes"
Expand All @@ -9,15 +9,15 @@ import (
"io"
)

type W7DTH struct {
type W7 struct {
key []byte
}

func New() *W7DTH {
return &W7DTH{}
func New() *W7 {
return &W7{}
}

func (w *W7DTH) Key(generate string) (string, error) {
func (w *W7) Key(generate string) (string, error) {
if generate == "generate" {
key := make([]byte, 32)
_, err := rand.Read(key)
Expand All @@ -35,7 +35,7 @@ func (w *W7DTH) Key(generate string) (string, error) {
return generate, nil
}

func (w *W7DTH) Encrypt(data string) (string, error) {
func (w *W7) Encrypt(data string) (string, error) {
block, err := aes.NewCipher(w.key)
if err != nil {
return "", err
Expand All @@ -52,7 +52,7 @@ func (w *W7DTH) Encrypt(data string) (string, error) {
return hex.EncodeToString(ciphertext), nil
}

func (w *W7DTH) Decrypt(data string) (string, error) {
func (w *W7) Decrypt(data string) (string, error) {
ciphertext, err := hex.DecodeString(data)
if err != nil {
return "", err
Expand Down

0 comments on commit 75640a5

Please sign in to comment.