1
This commit is contained in:
parent
c796300e9b
commit
1e9ba955c3
5 changed files with 38 additions and 51 deletions
|
|
@ -1,36 +1,38 @@
|
|||
// go: ignore
|
||||
//go:build ignore
|
||||
|
||||
package main
|
||||
|
||||
// import (
|
||||
// "encoding/hex"
|
||||
// "fmt"
|
||||
// "time"
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
// "github.com/zeevdiukman/z/crypt"
|
||||
// "github.com/zeevdiukman/z/helper"
|
||||
// )
|
||||
"github.com/zeevdiukman/z/crypt"
|
||||
"github.com/zeevdiukman/z/helper"
|
||||
)
|
||||
|
||||
// func main() {
|
||||
// t := time.Now()
|
||||
// key := "1b1ef1cf714a412d57ec7be1647e6e1e7f8141a1cd009dd13b52041e5c62dbd6"
|
||||
// keyBytes, _ := hex.DecodeString(key)
|
||||
// plaintext := "hello, world!"
|
||||
// encryptedText, err := crypt.Encrypt(plaintext, keyBytes)
|
||||
func main() {
|
||||
var _ = crypt.Encrypt
|
||||
t := time.Now()
|
||||
key := "1b1ef1cf714a412d57ec7be1647e6e1e7f8141a1cd009dd13b52041e5c62dbd6"
|
||||
keyBytes, _ := hex.DecodeString(key)
|
||||
plaintext := "hello, world!"
|
||||
encryptedText, err := crypt.Encrypt(plaintext, keyBytes)
|
||||
|
||||
// if err != nil {
|
||||
// fmt.Println("Error encrypting:", err)
|
||||
// return
|
||||
// }
|
||||
// decryptedText, err := crypt.Decrypt(encryptedText, keyBytes)
|
||||
// if err != nil {
|
||||
// fmt.Println("Error decrypting:", err)
|
||||
// return
|
||||
// }
|
||||
// tt := time.Since(t)
|
||||
if err != nil {
|
||||
fmt.Println("Error encrypting:", err)
|
||||
return
|
||||
}
|
||||
decryptedText, err := crypt.Decrypt(encryptedText, keyBytes)
|
||||
if err != nil {
|
||||
fmt.Println("Error decrypting:", err)
|
||||
return
|
||||
}
|
||||
tt := time.Since(t)
|
||||
|
||||
// fmt.Println("Key:", key)
|
||||
// fmt.Println("Encrypted:", encryptedText)
|
||||
// fmt.Println("Decrypted:", decryptedText)
|
||||
// fmt.Println("Generated in", tt)
|
||||
// helper.PrintOldStyleMetrics()
|
||||
// }
|
||||
fmt.Println("Key:", key)
|
||||
fmt.Println("Encrypted:", encryptedText)
|
||||
fmt.Println("Decrypted:", decryptedText)
|
||||
fmt.Println("Generated in", tt)
|
||||
helper.PrintOldStyleMetrics()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//go:build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
|
@ -5,11 +7,6 @@ import (
|
|||
"github.com/zeevdiukman/z/helper"
|
||||
)
|
||||
|
||||
// ServeDNS calls f(w, r).
|
||||
//
|
||||
// func (f dns.HandlerFunc) ServeDNS(w dns.ResponseWriter, r *dns.Msg) {
|
||||
// f(w, r)
|
||||
// }
|
||||
func main() {
|
||||
dnsApp := dns.New()
|
||||
dnsApp.Mux.HandleFunc(".", dnsApp.HandleTypeA)
|
||||
|
|
|
|||
3
go.work
3
go.work
|
|
@ -2,7 +2,8 @@ go 1.23.0
|
|||
|
||||
use (
|
||||
./
|
||||
./pkg/crypt
|
||||
./pkg/dns
|
||||
./pkg/helper
|
||||
./pkg/crypt
|
||||
|
||||
)
|
||||
|
|
|
|||
15
main.go
15
main.go
|
|
@ -1,18 +1,5 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/zeevdiukman/z/dns"
|
||||
"github.com/zeevdiukman/z/helper"
|
||||
)
|
||||
|
||||
// ServeDNS calls f(w, r).
|
||||
//
|
||||
// func (f dns.HandlerFunc) ServeDNS(w dns.ResponseWriter, r *dns.Msg) {
|
||||
// f(w, r)
|
||||
// }
|
||||
func main() {
|
||||
dnsApp := dns.New()
|
||||
dnsApp.Mux.HandleFunc(".", dnsApp.HandleTypeA)
|
||||
go dnsApp.Run()
|
||||
helper.StartHTTP()
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package zcrypt
|
||||
package crypt
|
||||
|
||||
import (
|
||||
"crypto/aes"
|
||||
Loading…
Reference in a new issue