5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-19 02:19:31 +08:00
wails/v3/examples/services/hashes/hashes.go
Atterpac e316cd0719
[V3] Plugins implemenations (#3570)
* plugin handler and lifecycle

* rebase

* remove reflect

s

* remove Config and NewPlugin from plugin template

* Remove plugin manager, generation of plugin interface

* implement http handlers for services

remove log

trim path

prefix wails/services

* update plugine example

* Misc updates

* Ported plugins to services, rewritten example

* Added fileserver

* Update OnStartup and use a context for the application

* Rename PathPrefix to Route. Create docs.

* Use service config copy. Add Name to Service Options. Improve service generation.

* Use service config copy. Add Name to Service Options. Improve service generation. Update README

* Remove rogue db

* Update changelog.md

---------

Co-authored-by: Lea O'Anthony <lea.anthony@gmail.com>
2024-09-01 17:26:22 +10:00

41 lines
710 B
Go

package hashes
import (
"crypto/md5"
"crypto/sha1"
"crypto/sha256"
"encoding/hex"
)
type Hashes struct {
MD5 string `json:"md5"`
SHA1 string `json:"sha1"`
SHA256 string `json:"sha256"`
}
func (h *Hashes) Generate(s string) Hashes {
md5Hash := md5.Sum([]byte(s))
sha1Hash := sha1.Sum([]byte(s))
sha256Hash := sha256.Sum256([]byte(s))
return Hashes{
MD5: hex.EncodeToString(md5Hash[:]),
SHA1: hex.EncodeToString(sha1Hash[:]),
SHA256: hex.EncodeToString(sha256Hash[:]),
}
}
func New() *Hashes {
return &Hashes{}
}
func (h *Hashes) OnShutdown() error { return nil }
func (h *Hashes) Name() string {
return "Hashes Service"
}
func (h *Hashes) OnStartup() error {
return nil
}