mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
add more example for package gres; RELEASE updates
This commit is contained in:
25
.example/os/gres/gres_pack.go
Normal file
25
.example/os/gres/gres_pack.go
Normal file
@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/crypto/gaes"
|
||||
"github.com/gogf/gf/os/gfile"
|
||||
"github.com/gogf/gf/os/gres"
|
||||
)
|
||||
|
||||
var (
|
||||
CryptoKey = []byte("x76cgqt36i9c863bzmotuf8626dxiwu0")
|
||||
)
|
||||
|
||||
func main() {
|
||||
binContent, err := gres.Pack("public,config")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
binContent, err = gaes.Encrypt(binContent, CryptoKey)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := gfile.PutBytes("data.bin", binContent); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
23
.example/os/gres/gres_unpack.go
Normal file
23
.example/os/gres/gres_unpack.go
Normal file
@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/crypto/gaes"
|
||||
"github.com/gogf/gf/os/gfile"
|
||||
"github.com/gogf/gf/os/gres"
|
||||
)
|
||||
|
||||
var (
|
||||
CryptoKey = []byte("x76cgqt36i9c863bzmotuf8626dxiwu0")
|
||||
)
|
||||
|
||||
func main() {
|
||||
binContent := gfile.GetBytes("data.bin")
|
||||
binContent, err := gaes.Decrypt(binContent, CryptoKey)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := gres.Add(binContent); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
gres.Dump()
|
||||
}
|
||||
Reference in New Issue
Block a user