Files
pentapass/crypto/crypto.go
2024-08-13 15:18:22 +02:00

39 lines
609 B
Go

package crypto
import (
"encoding/json"
"github.com/google/uuid"
)
type Password struct {
Service string `json:"Service"`
Url string `json:"Url"`
Username string `json:"Username"`
Password string `json:"Password"`
Tags []string `json:"Tags"`
Id uuid.UUID `json:"Id"`
}
func (p *Password) ToJson() ([]byte, error) {
return json.Marshal(p)
}
func GetPasswordFromJson(b []byte) (Password, error) {
var result Password
err := json.Unmarshal(b, result)
if err != nil {
return Password{}, err
}
return result, nil
}
func NewPassword() *Password {
return &Password{
Id: uuid.New(),
}
}