Add func read and write to JSON

This commit is contained in:
Archie Fox
2025-03-08 21:18:39 +03:00
parent 26e125577d
commit f45e200c6e
6 changed files with 120 additions and 27 deletions

View File

@@ -1,14 +1,12 @@
package account
import (
"encoding/json"
"errors"
"fmt"
"github.com/fatih/color"
"math/rand/v2"
"net/url"
"time"
"github.com/fatih/color"
)
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGIJKLMNOPQRSTUVWXYZ1234567890-*!?()#$%&")
@@ -22,17 +20,9 @@ type Account struct {
}
// метод вывода пароля
func (acc *Account) OutputPassword() {
func (acc *Account) Output() {
c := color.New(color.FgRed, color.Italic, color.Bold)
c.Printf("password: %v\n", acc.Password)
}
func (acc *Account) ToBytes() ([]byte, error) {
file, err := json.Marshal(acc)
if err != nil {
return nil, err
}
return file, nil
c.Printf("password: %v, login: %v, URL: %v\n", acc.Password, acc.Login, acc.Url)
}
// метод генерации пароля