1
This commit is contained in:
parent
c4227475f2
commit
3c315f7df2
1 changed files with 60 additions and 1 deletions
61
README.md
61
README.md
|
|
@ -1 +1,60 @@
|
|||
# z
|
||||
# Z library
|
||||
|
||||
# dns example
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/zeevdiukman/z/dns"
|
||||
"github.com/zeevdiukman/z/helper"
|
||||
)
|
||||
|
||||
func main() {
|
||||
dnsApp := dns.New()
|
||||
dnsApp.Mux.HandleFunc(".", dnsApp.HandleTypeA)
|
||||
go dnsApp.Run()
|
||||
helper.StartHTTP()
|
||||
}
|
||||
```
|
||||
|
||||
# crypt example
|
||||
|
||||
```go
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/zeevdiukman/z/crypt"
|
||||
"github.com/zeevdiukman/z/helper"
|
||||
)
|
||||
|
||||
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)
|
||||
|
||||
fmt.Println("Key:", key)
|
||||
fmt.Println("Encrypted:", encryptedText)
|
||||
fmt.Println("Decrypted:", decryptedText)
|
||||
fmt.Println("Generated in", tt)
|
||||
helper.PrintOldStyleMetrics()
|
||||
}
|
||||
```
|
||||
Loading…
Reference in a new issue