diff --git a/docs/concurrency.md b/docs/concurrency.md
index 891fc0c..5e74b18 100644
--- a/docs/concurrency.md
+++ b/docs/concurrency.md
@@ -90,14 +90,14 @@ func main() {
out := make(chan (<-chan int))
go func() {
defer close(out)
- for i := 1; i <= 5; i++ {
- stream := make(chan int, 1)
- stream <- i
- close(stream)
- out <- stream
- }
+ for i := 1; i <= 5; i++ {
+ stream := make(chan int, 1)
+ stream <- i
+ close(stream)
+ out <- stream
+ }
}()
- return out
+ return out
}
for v := range c.Bridge(ctx, genVals()) {
@@ -134,21 +134,21 @@ import (
)
func main() {
- ctx, cancel := context.WithCancel(context.Background())
- defer cancel()
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
- c := concurrency.NewChannel[int]()
- channels := make([]<-chan int, 2)
+ c := concurrency.NewChannel[int]()
+ channels := make([]<-chan int, 2)
- for i := 0; i < 2; i++ {
- channels[i] = c.Take(ctx, c.Repeat(ctx, i), 2)
- }
+ for i := 0; i < 2; i++ {
+ channels[i] = c.Take(ctx, c.Repeat(ctx, i), 2)
+ }
- chs := c.FanIn(ctx, channels...)
+ chs := c.FanIn(ctx, channels...)
- for v := range chs {
- fmt.Println(v) //1 1 0 0 or 0 0 1 1
- }
+ for v := range chs {
+ fmt.Println(v) //1 1 0 0 or 0 0 1 1
+ }
}
```
@@ -173,21 +173,21 @@ import (
)
func main() {
- ctx, cancel := context.WithCancel(context.Background())
- defer cancel()
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
- c := concurrency.NewChannel[int]()
- intStream := c.Take(ctx, c.Repeat(ctx, 1, 2), 4)
+ c := concurrency.NewChannel[int]()
+ intStream := c.Take(ctx, c.Repeat(ctx, 1, 2), 4)
- for v := range intStream {
- fmt.Println(v)
- }
+ for v := range intStream {
+ fmt.Println(v)
+ }
- // Output:
- // 1
- // 2
- // 1
- // 2
+ // Output:
+ // 1
+ // 2
+ // 1
+ // 2
}
```
@@ -212,20 +212,20 @@ import (
)
func main() {
- ctx, cancel := context.WithCancel(context.Background())
- defer cancel()
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
- c := concurrency.NewChannel[int]()
- intStream := c.Generate(ctx, 1, 2, 3)
+ c := concurrency.NewChannel[int]()
+ intStream := c.Generate(ctx, 1, 2, 3)
- fmt.Println(<-intStream)
- fmt.Println(<-intStream)
- fmt.Println(<-intStream)
+ fmt.Println(<-intStream)
+ fmt.Println(<-intStream)
+ fmt.Println(<-intStream)
- // Output:
- // 1
- // 2
- // 3
+ // Output:
+ // 1
+ // 2
+ // 3
}
```
@@ -250,24 +250,24 @@ import (
)
func main() {
- ctx, cancel := context.WithCancel(context.Background())
- defer cancel()
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
- fn := func() string {
- return "hello"
- }
+ fn := func() string {
+ return "hello"
+ }
- c := concurrency.NewChannel[string]()
- intStream := c.Take(ctx, c.RepeatFn(ctx, fn), 3)
+ c := concurrency.NewChannel[string]()
+ intStream := c.Take(ctx, c.RepeatFn(ctx, fn), 3)
- for v := range intStream {
- fmt.Println(v)
- }
+ for v := range intStream {
+ fmt.Println(v)
+ }
- // Output:
- // hello
- // hello
- // hello
+ // Output:
+ // hello
+ // hello
+ // hello
}
```
@@ -292,25 +292,25 @@ import (
)
func main() {
- sig := func(after time.Duration) <-chan any {
- c := make(chan any)
- go func() {
- defer close(c)
- time.Sleep(after)
- }()
- return c
- }
+ sig := func(after time.Duration) <-chan any {
+ c := make(chan any)
+ go func() {
+ defer close(c)
+ time.Sleep(after)
+ }()
+ return c
+ }
- start := time.Now()
+ start := time.Now()
- c := concurrency.NewChannel[any]()
- <-c.Or(
- sig(1*time.Second),
- sig(2*time.Second),
- sig(3*time.Second),
- )
+ c := concurrency.NewChannel[any]()
+ <-c.Or(
+ sig(1*time.Second),
+ sig(2*time.Second),
+ sig(3*time.Second),
+ )
- fmt.Println("done after %v", time.Since(start)) //1.003s
+ fmt.Println("done after %v", time.Since(start)) //1.003s
}
```
@@ -335,20 +335,20 @@ import (
)
func main() {
- ctx, cancel := context.WithCancel(context.Background())
- defer cancel()
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
- c := concurrency.NewChannel[int]()
- intStream := c.Take(ctx, c.Repeat(ctx, 1), 3)
+ c := concurrency.NewChannel[int]()
+ intStream := c.Take(ctx, c.Repeat(ctx, 1), 3)
- for v := range c.OrDone(ctx, intStream) {
- fmt.Println(v)
- }
+ for v := range c.OrDone(ctx, intStream) {
+ fmt.Println(v)
+ }
- // Output:
- // 1
- // 1
- // 1
+ // Output:
+ // 1
+ // 1
+ // 1
}
```
@@ -373,28 +373,28 @@ import (
)
func main() {
- ctx, cancel := context.WithCancel(context.Background())
- defer cancel()
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
- numbers := make(chan int, 5)
- numbers <- 1
- numbers <- 2
- numbers <- 3
- numbers <- 4
- numbers <- 5
- defer close(numbers)
+ numbers := make(chan int, 5)
+ numbers <- 1
+ numbers <- 2
+ numbers <- 3
+ numbers <- 4
+ numbers <- 5
+ defer close(numbers)
- c := concurrency.NewChannel[int]()
- intStream := c.Take(ctx, numbers, 3)
+ c := concurrency.NewChannel[int]()
+ intStream := c.Take(ctx, numbers, 3)
- for v := range intStream {
- fmt.Println(v)
- }
+ for v := range intStream {
+ fmt.Println(v)
+ }
- // Output:
- // 1
- // 2
- // 3
+ // Output:
+ // 1
+ // 2
+ // 3
}
```
@@ -419,23 +419,23 @@ import (
)
func main() {
- ctx, cancel := context.WithCancel(context.Background())
- defer cancel()
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
- c := concurrency.NewChannel[int]()
- intStream := c.Take(ctx, c.Repeat(ctx, 1), 2)
+ c := concurrency.NewChannel[int]()
+ intStream := c.Take(ctx, c.Repeat(ctx, 1), 2)
- ch1, ch2 := c.Tee(ctx, intStream)
+ ch1, ch2 := c.Tee(ctx, intStream)
- for v := range ch1 {
- fmt.Println(v)
- fmt.Println(<-ch2)
- }
-
- // Output:
- // 1
- // 1
- // 1
- // 1
+ for v := range ch1 {
+ fmt.Println(v)
+ fmt.Println(<-ch2)
+ }
+
+ // Output:
+ // 1
+ // 1
+ // 1
+ // 1
}
```
\ No newline at end of file
diff --git a/docs/concurrency_zh-CN.md b/docs/concurrency_zh-CN.md
index 1f553de..0d555ed 100644
--- a/docs/concurrency_zh-CN.md
+++ b/docs/concurrency_zh-CN.md
@@ -82,34 +82,34 @@ import (
)
func main() {
- ctx, cancel := context.WithCancel(context.Background())
- defer cancel()
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
- c := concurrency.NewChannel[int]()
- genVals := func() <-chan <-chan int {
- out := make(chan (<-chan int))
- go func() {
- defer close(out)
- for i := 1; i <= 5; i++ {
- stream := make(chan int, 1)
- stream <- i
- close(stream)
- out <- stream
- }
- }()
- return out
- }
+ c := concurrency.NewChannel[int]()
+ genVals := func() <-chan <-chan int {
+ out := make(chan (<-chan int))
+ go func() {
+ defer close(out)
+ for i := 1; i <= 5; i++ {
+ stream := make(chan int, 1)
+ stream <- i
+ close(stream)
+ out <- stream
+ }
+ }()
+ return out
+ }
- for v := range c.Bridge(ctx, genVals()) {
- fmt.Println(v)
- }
+ for v := range c.Bridge(ctx, genVals()) {
+ fmt.Println(v)
+ }
- // Output:
- // 1
- // 2
- // 3
- // 4
- // 5
+ // Output:
+ // 1
+ // 2
+ // 3
+ // 4
+ // 5
}
```
@@ -134,21 +134,21 @@ import (
)
func main() {
- ctx, cancel := context.WithCancel(context.Background())
- defer cancel()
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
- c := concurrency.NewChannel[int]()
- channels := make([]<-chan int, 2)
+ c := concurrency.NewChannel[int]()
+ channels := make([]<-chan int, 2)
- for i := 0; i < 2; i++ {
- channels[i] = c.Take(ctx, c.Repeat(ctx, i), 2)
- }
+ for i := 0; i < 2; i++ {
+ channels[i] = c.Take(ctx, c.Repeat(ctx, i), 2)
+ }
- chs := c.FanIn(ctx, channels...)
+ chs := c.FanIn(ctx, channels...)
- for v := range chs {
- fmt.Println(v) //1 1 0 0 or 0 0 1 1
- }
+ for v := range chs {
+ fmt.Println(v) //1 1 0 0 or 0 0 1 1
+ }
}
```
@@ -173,20 +173,20 @@ import (
)
func main() {
- ctx, cancel := context.WithCancel(context.Background())
- defer cancel()
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
- c := concurrency.NewChannel[int]()
- intStream := c.Generate(ctx, 1, 2, 3)
+ c := concurrency.NewChannel[int]()
+ intStream := c.Generate(ctx, 1, 2, 3)
- fmt.Println(<-intStream)
- fmt.Println(<-intStream)
- fmt.Println(<-intStream)
+ fmt.Println(<-intStream)
+ fmt.Println(<-intStream)
+ fmt.Println(<-intStream)
- // Output:
- // 1
- // 2
- // 3
+ // Output:
+ // 1
+ // 2
+ // 3
}
```
@@ -211,21 +211,21 @@ import (
)
func main() {
- ctx, cancel := context.WithCancel(context.Background())
- defer cancel()
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
- c := concurrency.NewChannel[int]()
- intStream := c.Take(ctx, c.Repeat(ctx, 1, 2), 4)
+ c := concurrency.NewChannel[int]()
+ intStream := c.Take(ctx, c.Repeat(ctx, 1, 2), 4)
- for v := range intStream {
- fmt.Println(v)
- }
+ for v := range intStream {
+ fmt.Println(v)
+ }
- // Output:
- // 1
- // 2
- // 1
- // 2
+ // Output:
+ // 1
+ // 2
+ // 1
+ // 2
}
```
@@ -250,23 +250,23 @@ import (
)
func main() {
- ctx, cancel := context.WithCancel(context.Background())
- defer cancel()
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
- fn := func() string {
- return "hello"
- }
+ fn := func() string {
+ return "hello"
+ }
- c := concurrency.NewChannel[string]()
- intStream := c.Take(ctx, c.RepeatFn(ctx, fn), 3)
+ c := concurrency.NewChannel[string]()
+ intStream := c.Take(ctx, c.RepeatFn(ctx, fn), 3)
- for v := range intStream {
- fmt.Println(v)
- }
- // Output:
- // hello
- // hello
- // hello
+ for v := range intStream {
+ fmt.Println(v)
+ }
+ // Output:
+ // hello
+ // hello
+ // hello
}
```
@@ -291,25 +291,25 @@ import (
)
func main() {
- sig := func(after time.Duration) <-chan any {
- c := make(chan any)
- go func() {
- defer close(c)
- time.Sleep(after)
- }()
- return c
- }
+ sig := func(after time.Duration) <-chan any {
+ c := make(chan any)
+ go func() {
+ defer close(c)
+ time.Sleep(after)
+ }()
+ return c
+ }
- start := time.Now()
+ start := time.Now()
- c := concurrency.NewChannel[any]()
- <-c.Or(
- sig(1*time.Second),
- sig(2*time.Second),
- sig(3*time.Second),
- )
+ c := concurrency.NewChannel[any]()
+ <-c.Or(
+ sig(1*time.Second),
+ sig(2*time.Second),
+ sig(3*time.Second),
+ )
- fmt.Println("done after %v", time.Since(start)) //1.003s
+ fmt.Println("done after %v", time.Since(start)) //1.003s
}
```
@@ -334,20 +334,20 @@ import (
)
func main() {
- ctx, cancel := context.WithCancel(context.Background())
- defer cancel()
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
- c := concurrency.NewChannel[int]()
- intStream := c.Take(ctx, c.Repeat(ctx, 1), 3)
+ c := concurrency.NewChannel[int]()
+ intStream := c.Take(ctx, c.Repeat(ctx, 1), 3)
- for v := range c.OrDone(ctx, intStream) {
- fmt.Println(v)
- }
+ for v := range c.OrDone(ctx, intStream) {
+ fmt.Println(v)
+ }
- // Output:
- // 1
- // 1
- // 1
+ // Output:
+ // 1
+ // 1
+ // 1
}
```
@@ -372,28 +372,28 @@ import (
)
func main() {
- ctx, cancel := context.WithCancel(context.Background())
- defer cancel()
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
- numbers := make(chan int, 5)
- numbers <- 1
- numbers <- 2
- numbers <- 3
- numbers <- 4
- numbers <- 5
- defer close(numbers)
+ numbers := make(chan int, 5)
+ numbers <- 1
+ numbers <- 2
+ numbers <- 3
+ numbers <- 4
+ numbers <- 5
+ defer close(numbers)
- c := concurrency.NewChannel[int]()
- intStream := c.Take(ctx, numbers, 3)
+ c := concurrency.NewChannel[int]()
+ intStream := c.Take(ctx, numbers, 3)
- for v := range intStream {
- fmt.Println(v)
- }
+ for v := range intStream {
+ fmt.Println(v)
+ }
- // Output:
- // 1
- // 2
- // 3
+ // Output:
+ // 1
+ // 2
+ // 3
}
```
@@ -418,22 +418,22 @@ import (
)
func main() {
- ctx, cancel := context.WithCancel(context.Background())
- defer cancel()
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
- c := concurrency.NewChannel[int]()
- intStream := c.Take(ctx, c.Repeat(ctx, 1), 2)
+ c := concurrency.NewChannel[int]()
+ intStream := c.Take(ctx, c.Repeat(ctx, 1), 2)
- ch1, ch2 := c.Tee(ctx, intStream)
+ ch1, ch2 := c.Tee(ctx, intStream)
- for v := range ch1 {
- fmt.Println(v)
- fmt.Println(<-ch2)
- }
- // Output:
- // 1
- // 1
- // 1
- // 1
+ for v := range ch1 {
+ fmt.Println(v)
+ fmt.Println(<-ch2)
+ }
+ // Output:
+ // 1
+ // 1
+ // 1
+ // 1
}
```
\ No newline at end of file
diff --git a/docs/condition.md b/docs/condition.md
index 52a825f..4a3de95 100644
--- a/docs/condition.md
+++ b/docs/condition.md
@@ -57,48 +57,48 @@ import (
)
func main() {
- // bool
- result1 := condition.Bool(false)
- result2 := condition.Bool(true)
- fmt.Println(result1) // false
- fmt.Println(result2) // true
+ // bool
+ result1 := condition.Bool(false)
+ result2 := condition.Bool(true)
+ fmt.Println(result1) // false
+ fmt.Println(result2) // true
- // integer
- result3 := condition.Bool(0)
- result4 := condition.Bool(1)
- fmt.Println(result3) // false
- fmt.Println(result4) // true
+ // integer
+ result3 := condition.Bool(0)
+ result4 := condition.Bool(1)
+ fmt.Println(result3) // false
+ fmt.Println(result4) // true
- // string
- result5 := condition.Bool("")
- result6 := condition.Bool(" ")
- fmt.Println(result5) // false
- fmt.Println(result6) // true
+ // string
+ result5 := condition.Bool("")
+ result6 := condition.Bool(" ")
+ fmt.Println(result5) // false
+ fmt.Println(result6) // true
- // slice
- nums := []int{}
- result7 := condition.Bool(nums)
+ // slice
+ nums := []int{}
+ result7 := condition.Bool(nums)
- nums = append(nums, 1, 2)
- result8 := condition.Bool(nums)
- fmt.Println(result7) // false
- fmt.Println(result8) // true
+ nums = append(nums, 1, 2)
+ result8 := condition.Bool(nums)
+ fmt.Println(result7) // false
+ fmt.Println(result8) // true
- // struct
- result9 = condition.Bool(struct{}{})
- fmt.Println(result8) // false
+ // struct
+ result9 = condition.Bool(struct{}{})
+ fmt.Println(result8) // false
- // Output:
- // false
- // true
- // false
- // true
- // false
- // true
- // false
- // true
- // false
+ // Output:
+ // false
+ // true
+ // false
+ // true
+ // false
+ // true
+ // false
+ // true
+ // false
}
```
@@ -122,10 +122,10 @@ import (
)
func main() {
- fmt.Println(condition.And(0, 1)) // false
- fmt.Println(condition.And(0, "")) // false
- fmt.Println(condition.And(0, "0")) // false
- fmt.Println(condition.And(1, "0")) // true
+ fmt.Println(condition.And(0, 1)) // false
+ fmt.Println(condition.And(0, "")) // false
+ fmt.Println(condition.And(0, "0")) // false
+ fmt.Println(condition.And(1, "0")) // true
}
```
@@ -150,10 +150,10 @@ import (
)
func main() {
- fmt.Println(condition.Or(0, "")) // false
- fmt.Println(condition.Or(0, 1)) // true
- fmt.Println(condition.Or(0, "0")) // true
- fmt.Println(condition.Or(1, "0")) // true
+ fmt.Println(condition.Or(0, "")) // false
+ fmt.Println(condition.Or(0, 1)) // true
+ fmt.Println(condition.Or(0, "0")) // true
+ fmt.Println(condition.Or(1, "0")) // true
}
```
@@ -178,10 +178,10 @@ import (
)
func main() {
- fmt.Println(condition.Xor(0, 0)) // false
- fmt.Println(condition.Xor(0, 1)) // true
- fmt.Println(condition.Xor(1, 0)) // true
- fmt.Println(condition.Xor(1, 1)) // false
+ fmt.Println(condition.Xor(0, 0)) // false
+ fmt.Println(condition.Xor(0, 1)) // true
+ fmt.Println(condition.Xor(1, 0)) // true
+ fmt.Println(condition.Xor(1, 1)) // false
}
```
@@ -206,10 +206,10 @@ import (
)
func main() {
- fmt.Println(condition.Nor(0, 0)) // true
- fmt.Println(condition.Nor(0, 1)) // false
- fmt.Println(condition.Nor(1, 0)) // false
- fmt.Println(condition.Nor(1, 1)) // false
+ fmt.Println(condition.Nor(0, 0)) // true
+ fmt.Println(condition.Nor(0, 1)) // false
+ fmt.Println(condition.Nor(1, 0)) // false
+ fmt.Println(condition.Nor(1, 1)) // false
}
```
@@ -233,10 +233,10 @@ import (
)
func main() {
- fmt.Println(condition.Xnor(0, 0)) // true
- fmt.Println(condition.Xnor(0, 1)) // false
- fmt.Println(condition.Xnor(1, 0)) // false
- fmt.Println(condition.Xnor(1, 1)) // true
+ fmt.Println(condition.Xnor(0, 0)) // true
+ fmt.Println(condition.Xnor(0, 1)) // false
+ fmt.Println(condition.Xnor(1, 0)) // false
+ fmt.Println(condition.Xnor(1, 1)) // true
}
```
@@ -260,10 +260,10 @@ import (
)
func main() {
- fmt.Println(condition.Nand(0, 0)) // true
- fmt.Println(condition.Nand(0, 1)) // true
- fmt.Println(condition.Nand(1, 0)) // true
- fmt.Println(condition.Nand(1, 1)) // false
+ fmt.Println(condition.Nand(0, 0)) // true
+ fmt.Println(condition.Nand(0, 1)) // true
+ fmt.Println(condition.Nand(1, 0)) // true
+ fmt.Println(condition.Nand(1, 1)) // false
}
```
@@ -288,18 +288,18 @@ import (
)
func main() {
- conditionTrue := 2 > 1
- result1 := condition.TernaryOperator(conditionTrue, 0, 1)
+ conditionTrue := 2 > 1
+ result1 := condition.TernaryOperator(conditionTrue, 0, 1)
- conditionFalse := 2 > 3
- result2 := condition.TernaryOperator(conditionFalse, 0, 1)
-
- fmt.Println(result1)
- fmt.Println(result2)
+ conditionFalse := 2 > 3
+ result2 := condition.TernaryOperator(conditionFalse, 0, 1)
+
+ fmt.Println(result1)
+ fmt.Println(result2)
- // Output:
- // 0
- // 1
+ // Output:
+ // 0
+ // 1
}
```
diff --git a/docs/condition_zh-CN.md b/docs/condition_zh-CN.md
index 758199b..59e1ce1 100644
--- a/docs/condition_zh-CN.md
+++ b/docs/condition_zh-CN.md
@@ -56,48 +56,48 @@ import (
)
func main() {
- // bool
- result1 := condition.Bool(false)
- result2 := condition.Bool(true)
- fmt.Println(result1) // false
- fmt.Println(result2) // true
+ // bool
+ result1 := condition.Bool(false)
+ result2 := condition.Bool(true)
+ fmt.Println(result1) // false
+ fmt.Println(result2) // true
- // integer
- result3 := condition.Bool(0)
- result4 := condition.Bool(1)
- fmt.Println(result3) // false
- fmt.Println(result4) // true
+ // integer
+ result3 := condition.Bool(0)
+ result4 := condition.Bool(1)
+ fmt.Println(result3) // false
+ fmt.Println(result4) // true
- // string
- result5 := condition.Bool("")
- result6 := condition.Bool(" ")
- fmt.Println(result5) // false
- fmt.Println(result6) // true
+ // string
+ result5 := condition.Bool("")
+ result6 := condition.Bool(" ")
+ fmt.Println(result5) // false
+ fmt.Println(result6) // true
- // slice
- nums := []int{}
- result7 := condition.Bool(nums)
+ // slice
+ nums := []int{}
+ result7 := condition.Bool(nums)
- nums = append(nums, 1, 2)
- result8 := condition.Bool(nums)
- fmt.Println(result7) // false
- fmt.Println(result8) // true
+ nums = append(nums, 1, 2)
+ result8 := condition.Bool(nums)
+ fmt.Println(result7) // false
+ fmt.Println(result8) // true
- // struct
- result9 = condition.Bool(struct{}{})
- fmt.Println(result8) // false
+ // struct
+ result9 = condition.Bool(struct{}{})
+ fmt.Println(result8) // false
- // Output:
- // false
- // true
- // false
- // true
- // false
- // true
- // false
- // true
- // false
+ // Output:
+ // false
+ // true
+ // false
+ // true
+ // false
+ // true
+ // false
+ // true
+ // false
}
```
@@ -120,10 +120,10 @@ import (
)
func main() {
- fmt.Println(condition.And(0, 1)) // false
- fmt.Println(condition.And(0, "")) // false
- fmt.Println(condition.And(0, "0")) // false
- fmt.Println(condition.And(1, "0")) // true
+ fmt.Println(condition.And(0, 1)) // false
+ fmt.Println(condition.And(0, "")) // false
+ fmt.Println(condition.And(0, "0")) // false
+ fmt.Println(condition.And(1, "0")) // true
}
```
@@ -146,10 +146,10 @@ import (
)
func main() {
- fmt.Println(condition.Or(0, "")) // false
- fmt.Println(condition.Or(0, 1)) // true
- fmt.Println(condition.Or(0, "0")) // true
- fmt.Println(condition.Or(1, "0")) // true
+ fmt.Println(condition.Or(0, "")) // false
+ fmt.Println(condition.Or(0, 1)) // true
+ fmt.Println(condition.Or(0, "0")) // true
+ fmt.Println(condition.Or(1, "0")) // true
}
```
@@ -172,10 +172,10 @@ import (
)
func main() {
- fmt.Println(condition.Xor(0, 0)) // false
- fmt.Println(condition.Xor(0, 1)) // true
- fmt.Println(condition.Xor(1, 0)) // true
- fmt.Println(condition.Xor(1, 1)) // false
+ fmt.Println(condition.Xor(0, 0)) // false
+ fmt.Println(condition.Xor(0, 1)) // true
+ fmt.Println(condition.Xor(1, 0)) // true
+ fmt.Println(condition.Xor(1, 1)) // false
}
```
@@ -198,10 +198,10 @@ import (
)
func main() {
- fmt.Println(condition.Nor(0, 0)) // true
- fmt.Println(condition.Nor(0, 1)) // false
- fmt.Println(condition.Nor(1, 0)) // false
- fmt.Println(condition.Nor(1, 1)) // false
+ fmt.Println(condition.Nor(0, 0)) // true
+ fmt.Println(condition.Nor(0, 1)) // false
+ fmt.Println(condition.Nor(1, 0)) // false
+ fmt.Println(condition.Nor(1, 1)) // false
}
```
@@ -224,10 +224,10 @@ import (
)
func main() {
- fmt.Println(condition.Xnor(0, 0)) // true
- fmt.Println(condition.Xnor(0, 1)) // false
- fmt.Println(condition.Xnor(1, 0)) // false
- fmt.Println(condition.Xnor(1, 1)) // true
+ fmt.Println(condition.Xnor(0, 0)) // true
+ fmt.Println(condition.Xnor(0, 1)) // false
+ fmt.Println(condition.Xnor(1, 0)) // false
+ fmt.Println(condition.Xnor(1, 1)) // true
}
```
@@ -250,10 +250,10 @@ import (
)
func main() {
- fmt.Println(condition.Nand(0, 0)) // true
- fmt.Println(condition.Nand(0, 1)) // true
- fmt.Println(condition.Nand(1, 0)) // true
- fmt.Println(condition.Nand(1, 1)) // false
+ fmt.Println(condition.Nand(0, 0)) // true
+ fmt.Println(condition.Nand(0, 1)) // true
+ fmt.Println(condition.Nand(1, 0)) // true
+ fmt.Println(condition.Nand(1, 1)) // false
}
```
@@ -276,18 +276,18 @@ import (
)
func main() {
- conditionTrue := 2 > 1
- result1 := condition.TernaryOperator(conditionTrue, 0, 1)
+ conditionTrue := 2 > 1
+ result1 := condition.TernaryOperator(conditionTrue, 0, 1)
- conditionFalse := 2 > 3
- result2 := condition.TernaryOperator(conditionFalse, 0, 1)
-
- fmt.Println(result1)
- fmt.Println(result2)
+ conditionFalse := 2 > 3
+ result2 := condition.TernaryOperator(conditionFalse, 0, 1)
+
+ fmt.Println(result1)
+ fmt.Println(result2)
- // Output:
- // 0
- // 1
+ // Output:
+ // 0
+ // 1
}
```
diff --git a/docs/cryptor.md b/docs/cryptor.md
index 1cb2da9..735e15e 100644
--- a/docs/cryptor.md
+++ b/docs/cryptor.md
@@ -82,15 +82,15 @@ import (
func main() {
data := "hello"
- key := "abcdefghijklmnop"
+ key := "abcdefghijklmnop"
- encrypted := cryptor.AesEcbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.AesEcbDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.AesEcbEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.AesEcbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -115,15 +115,15 @@ import (
func main() {
data := "hello"
- key := "abcdefghijklmnop"
+ key := "abcdefghijklmnop"
- encrypted := cryptor.AesEcbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.AesEcbDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.AesEcbEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.AesEcbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -148,15 +148,15 @@ import (
func main() {
data := "hello"
- key := "abcdefghijklmnop"
+ key := "abcdefghijklmnop"
- encrypted := cryptor.AesCbcEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.AesCbcDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.AesCbcEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.AesCbcDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -182,15 +182,15 @@ import (
func main() {
data := "hello"
- key := "abcdefghijklmnop"
+ key := "abcdefghijklmnop"
- encrypted := cryptor.AesCbcEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.AesCbcDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.AesCbcEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.AesCbcDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -216,15 +216,15 @@ import (
func main() {
data := "hello"
- key := "abcdefghijklmnop"
+ key := "abcdefghijklmnop"
- encrypted := cryptor.AesCtrCrypt([]byte(data), []byte(key))
- decrypted := cryptor.AesCtrCrypt(encrypted, []byte(key))
+ encrypted := cryptor.AesCtrCrypt([]byte(data), []byte(key))
+ decrypted := cryptor.AesCtrCrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -250,15 +250,15 @@ import (
func main() {
data := "hello"
- key := "abcdefghijklmnop"
+ key := "abcdefghijklmnop"
- encrypted := cryptor.AesCfbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.AesCfbDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.AesCfbEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.AesCfbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -284,15 +284,15 @@ import (
func main() {
data := "hello"
- key := "abcdefghijklmnop"
+ key := "abcdefghijklmnop"
- encrypted := cryptor.AesCfbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.AesCfbDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.AesCfbEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.AesCfbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -318,15 +318,15 @@ import (
func main() {
data := "hello"
- key := "abcdefghijklmnop"
+ key := "abcdefghijklmnop"
- encrypted := cryptor.AesOfbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.AesCfbDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.AesOfbEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.AesCfbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
### AesOfbDecrypt
@@ -351,15 +351,15 @@ import (
func main() {
data := "hello"
- key := "abcdefghijklmnop"
+ key := "abcdefghijklmnop"
- encrypted := cryptor.AesOfbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.AesCfbDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.AesOfbEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.AesCfbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -384,10 +384,10 @@ import (
func main() {
base64Str := cryptor.Base64StdEncode("hello")
- fmt.Println(base64Str)
+ fmt.Println(base64Str)
- // Output:
- // aGVsbG8=
+ // Output:
+ // aGVsbG8=
}
```
### Base64StdDecode
@@ -412,10 +412,10 @@ import (
func main() {
str := cryptor.Base64StdDecode("aGVsbG8=")
- fmt.Println(str)
+ fmt.Println(str)
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -441,16 +441,16 @@ import (
func main() {
data := "hello"
- key := "abcdefgh"
+ key := "abcdefgh"
- encrypted := cryptor.DesEcbEncrypt([]byte(data), []byte(key))
+ encrypted := cryptor.DesEcbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.DesEcbDecrypt(encrypted, []byte(key))
+ decrypted := cryptor.DesEcbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
### DesEcbDecrypt
@@ -475,16 +475,16 @@ import (
func main() {
data := "hello"
- key := "abcdefgh"
+ key := "abcdefgh"
- encrypted := cryptor.DesEcbEncrypt([]byte(data), []byte(key))
+ encrypted := cryptor.DesEcbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.DesEcbDecrypt(encrypted, []byte(key))
+ decrypted := cryptor.DesEcbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -510,15 +510,15 @@ import (
func main() {
data := "hello"
- key := "abcdefgh"
+ key := "abcdefgh"
- encrypted := cryptor.DesCbcEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.DesCbcDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.DesCbcEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.DesCbcDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -544,15 +544,15 @@ import (
func main() {
data := "hello"
- key := "abcdefgh"
+ key := "abcdefgh"
- encrypted := cryptor.DesCbcEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.DesCbcDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.DesCbcEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.DesCbcDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
### DesCtrCrypt
@@ -577,15 +577,15 @@ import (
func main() {
data := "hello"
- key := "abcdefgh"
+ key := "abcdefgh"
- encrypted := cryptor.DesCtrCrypt([]byte(data), []byte(key))
- decrypted := cryptor.DesCtrCrypt(encrypted, []byte(key))
+ encrypted := cryptor.DesCtrCrypt([]byte(data), []byte(key))
+ decrypted := cryptor.DesCtrCrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -611,15 +611,15 @@ import (
func main() {
data := "hello"
- key := "abcdefgh"
+ key := "abcdefgh"
- encrypted := cryptor.DesCfbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.DesCfbDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.DesCfbEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.DesCfbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
### DesCfbDecrypt
@@ -644,15 +644,15 @@ import (
func main() {
data := "hello"
- key := "abcdefgh"
+ key := "abcdefgh"
- encrypted := cryptor.DesCfbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.DesCfbDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.DesCfbEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.DesCfbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
### DesOfbEncrypt
@@ -677,15 +677,15 @@ import (
func main() {
data := "hello"
- key := "abcdefgh"
+ key := "abcdefgh"
- encrypted := cryptor.DesOfbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.DesOfbDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.DesOfbEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.DesOfbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
### DesOfbDecrypt
@@ -710,15 +710,15 @@ import (
func main() {
data := "hello"
- key := "abcdefgh"
+ key := "abcdefgh"
- encrypted := cryptor.DesOfbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.DesOfbDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.DesOfbEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.DesOfbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -743,14 +743,14 @@ import (
)
func main() {
- str := "hello"
- key := "12345"
+ str := "hello"
+ key := "12345"
- hms := cryptor.HmacMd5(str, key)
- fmt.Println(hms)
+ hms := cryptor.HmacMd5(str, key)
+ fmt.Println(hms)
- // Output:
- // e834306eab892d872525d4918a7a639a
+ // Output:
+ // e834306eab892d872525d4918a7a639a
}
```
### HmacSha1
@@ -775,13 +775,13 @@ import (
func main() {
str := "hello"
- key := "12345"
+ key := "12345"
- hms := cryptor.HmacSha1(str, key)
- fmt.Println(hms)
+ hms := cryptor.HmacSha1(str, key)
+ fmt.Println(hms)
- // Output:
- // 5c6a9db0cccb92e36ed0323fd09b7f936de9ace0
+ // Output:
+ // 5c6a9db0cccb92e36ed0323fd09b7f936de9ace0
}
```
### HmacSha256
@@ -806,13 +806,13 @@ import (
func main() {
str := "hello"
- key := "12345"
+ key := "12345"
- hms := cryptor.HmacSha256(str, key)
- fmt.Println(hms)
+ hms := cryptor.HmacSha256(str, key)
+ fmt.Println(hms)
- // Output:
- // 315bb93c4e989862ba09cb62e05d73a5f376cb36f0d786edab0c320d059fde75
+ // Output:
+ // 315bb93c4e989862ba09cb62e05d73a5f376cb36f0d786edab0c320d059fde75
}
```
@@ -838,13 +838,13 @@ import (
func main() {
str := "hello"
- key := "12345"
+ key := "12345"
- hms := cryptor.HmacSha512(str, key)
- fmt.Println(hms)
+ hms := cryptor.HmacSha512(str, key)
+ fmt.Println(hms)
- // Output:
- // dd8f1290a9dd23d354e2526d9a2e9ce8cffffdd37cb320800d1c6c13d2efc363288376a196c5458daf53f8e1aa6b45a6d856303d5c0a2064bff9785861d48cfc
+ // Output:
+ // dd8f1290a9dd23d354e2526d9a2e9ce8cffffdd37cb320800d1c6c13d2efc363288376a196c5458daf53f8e1aa6b45a6d856303d5c0a2064bff9785861d48cfc
}
```
@@ -872,11 +872,11 @@ import (
func main() {
str := "hello"
- md5Str := cryptor.Md5String(str)
- fmt.Println(md5Str)
+ md5Str := cryptor.Md5String(str)
+ fmt.Println(md5Str)
- // Output:
- // 5d41402abc4b2a76b9719d911017c592
+ // Output:
+ // 5d41402abc4b2a76b9719d911017c592
}
```
@@ -929,11 +929,11 @@ import (
func main() {
str := "hello"
- result := cryptor.Sha1(str)
- fmt.Println(result)
+ result := cryptor.Sha1(str)
+ fmt.Println(result)
- // Output:
- // aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
+ // Output:
+ // aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
}
```
@@ -960,11 +960,11 @@ import (
func main() {
str := "hello"
- result := cryptor.Sha256(str)
- fmt.Println(result)
+ result := cryptor.Sha256(str)
+ fmt.Println(result)
- // Output:
- // 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
+ // Output:
+ // 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
}
```
@@ -991,11 +991,11 @@ import (
func main() {
str := "hello"
- result := cryptor.Sha512(str)
- fmt.Println(result)
+ result := cryptor.Sha512(str)
+ fmt.Println(result)
- // Output:
- // 9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca72323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043
+ // Output:
+ // 9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca72323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043
}
```
@@ -1052,15 +1052,15 @@ func main() {
if err != nil {
return
}
-
+
data := []byte("hello")
encrypted := cryptor.RsaEncrypt(data, "rsa_public.pem")
decrypted := cryptor.RsaDecrypt(encrypted, "rsa_private.pem")
-
+
fmt.Println(string(decrypted))
// Output:
- // hello
+ // hello
}
```
@@ -1090,15 +1090,15 @@ func main() {
if err != nil {
return
}
-
+
data := []byte("hello")
encrypted := cryptor.RsaEncrypt(data, "rsa_public.pem")
decrypted := cryptor.RsaDecrypt(encrypted, "rsa_private.pem")
-
+
fmt.Println(string(decrypted))
// Output:
- // hello
+ // hello
}
```
diff --git a/docs/cryptor_zh-CN.md b/docs/cryptor_zh-CN.md
index 5f1650c..1166634 100644
--- a/docs/cryptor_zh-CN.md
+++ b/docs/cryptor_zh-CN.md
@@ -81,15 +81,15 @@ import (
func main() {
data := "hello"
- key := "abcdefghijklmnop"
+ key := "abcdefghijklmnop"
- encrypted := cryptor.AesEcbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.AesEcbDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.AesEcbEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.AesEcbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -114,15 +114,15 @@ import (
func main() {
data := "hello"
- key := "abcdefghijklmnop"
+ key := "abcdefghijklmnop"
- encrypted := cryptor.AesEcbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.AesEcbDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.AesEcbEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.AesEcbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -147,15 +147,15 @@ import (
func main() {
data := "hello"
- key := "abcdefghijklmnop"
+ key := "abcdefghijklmnop"
- encrypted := cryptor.AesCbcEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.AesCbcDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.AesCbcEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.AesCbcDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -181,15 +181,15 @@ import (
func main() {
data := "hello"
- key := "abcdefghijklmnop"
+ key := "abcdefghijklmnop"
- encrypted := cryptor.AesCbcEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.AesCbcDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.AesCbcEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.AesCbcDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -215,15 +215,15 @@ import (
func main() {
data := "hello"
- key := "abcdefghijklmnop"
+ key := "abcdefghijklmnop"
- encrypted := cryptor.AesCtrCrypt([]byte(data), []byte(key))
- decrypted := cryptor.AesCtrCrypt(encrypted, []byte(key))
+ encrypted := cryptor.AesCtrCrypt([]byte(data), []byte(key))
+ decrypted := cryptor.AesCtrCrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -249,15 +249,15 @@ import (
func main() {
data := "hello"
- key := "abcdefghijklmnop"
+ key := "abcdefghijklmnop"
- encrypted := cryptor.AesCfbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.AesCfbDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.AesCfbEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.AesCfbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -283,15 +283,15 @@ import (
func main() {
data := "hello"
- key := "abcdefghijklmnop"
+ key := "abcdefghijklmnop"
- encrypted := cryptor.AesCfbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.AesCfbDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.AesCfbEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.AesCfbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -317,15 +317,15 @@ import (
func main() {
data := "hello"
- key := "abcdefghijklmnop"
+ key := "abcdefghijklmnop"
- encrypted := cryptor.AesOfbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.AesCfbDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.AesOfbEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.AesCfbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
### AesOfbDecrypt
@@ -350,15 +350,15 @@ import (
func main() {
data := "hello"
- key := "abcdefghijklmnop"
+ key := "abcdefghijklmnop"
- encrypted := cryptor.AesOfbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.AesCfbDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.AesOfbEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.AesCfbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -383,10 +383,10 @@ import (
func main() {
base64Str := cryptor.Base64StdEncode("hello")
- fmt.Println(base64Str)
+ fmt.Println(base64Str)
- // Output:
- // aGVsbG8=
+ // Output:
+ // aGVsbG8=
}
```
### Base64StdDecode
@@ -411,10 +411,10 @@ import (
func main() {
str := cryptor.Base64StdDecode("aGVsbG8=")
- fmt.Println(str)
+ fmt.Println(str)
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -440,16 +440,16 @@ import (
func main() {
data := "hello"
- key := "abcdefgh"
+ key := "abcdefgh"
- encrypted := cryptor.DesEcbEncrypt([]byte(data), []byte(key))
+ encrypted := cryptor.DesEcbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.DesEcbDecrypt(encrypted, []byte(key))
+ decrypted := cryptor.DesEcbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
### DesEcbDecrypt
@@ -474,16 +474,16 @@ import (
func main() {
data := "hello"
- key := "abcdefgh"
+ key := "abcdefgh"
- encrypted := cryptor.DesEcbEncrypt([]byte(data), []byte(key))
+ encrypted := cryptor.DesEcbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.DesEcbDecrypt(encrypted, []byte(key))
+ decrypted := cryptor.DesEcbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -509,15 +509,15 @@ import (
func main() {
data := "hello"
- key := "abcdefgh"
+ key := "abcdefgh"
- encrypted := cryptor.DesCbcEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.DesCbcDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.DesCbcEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.DesCbcDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -543,15 +543,15 @@ import (
func main() {
data := "hello"
- key := "abcdefgh"
+ key := "abcdefgh"
- encrypted := cryptor.DesCbcEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.DesCbcDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.DesCbcEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.DesCbcDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
### DesCtrCrypt
@@ -576,15 +576,15 @@ import (
func main() {
data := "hello"
- key := "abcdefgh"
+ key := "abcdefgh"
- encrypted := cryptor.DesCtrCrypt([]byte(data), []byte(key))
- decrypted := cryptor.DesCtrCrypt(encrypted, []byte(key))
+ encrypted := cryptor.DesCtrCrypt([]byte(data), []byte(key))
+ decrypted := cryptor.DesCtrCrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -610,15 +610,15 @@ import (
func main() {
data := "hello"
- key := "abcdefgh"
+ key := "abcdefgh"
- encrypted := cryptor.DesCfbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.DesCfbDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.DesCfbEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.DesCfbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
### DesCfbDecrypt
@@ -643,15 +643,15 @@ import (
func main() {
data := "hello"
- key := "abcdefgh"
+ key := "abcdefgh"
- encrypted := cryptor.DesCfbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.DesCfbDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.DesCfbEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.DesCfbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
### DesOfbEncrypt
@@ -676,15 +676,15 @@ import (
func main() {
data := "hello"
- key := "abcdefgh"
+ key := "abcdefgh"
- encrypted := cryptor.DesOfbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.DesOfbDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.DesOfbEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.DesOfbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
### DesOfbDecrypt
@@ -709,15 +709,15 @@ import (
func main() {
data := "hello"
- key := "abcdefgh"
+ key := "abcdefgh"
- encrypted := cryptor.DesOfbEncrypt([]byte(data), []byte(key))
- decrypted := cryptor.DesOfbDecrypt(encrypted, []byte(key))
+ encrypted := cryptor.DesOfbEncrypt([]byte(data), []byte(key))
+ decrypted := cryptor.DesOfbDecrypt(encrypted, []byte(key))
- fmt.Println(string(decrypted))
+ fmt.Println(string(decrypted))
- // Output:
- // hello
+ // Output:
+ // hello
}
```
@@ -742,14 +742,14 @@ import (
)
func main() {
- str := "hello"
- key := "12345"
+ str := "hello"
+ key := "12345"
- hms := cryptor.HmacMd5(str, key)
- fmt.Println(hms)
+ hms := cryptor.HmacMd5(str, key)
+ fmt.Println(hms)
- // Output:
- // e834306eab892d872525d4918a7a639a
+ // Output:
+ // e834306eab892d872525d4918a7a639a
}
```
### HmacSha1
@@ -774,13 +774,13 @@ import (
func main() {
str := "hello"
- key := "12345"
+ key := "12345"
- hms := cryptor.HmacSha1(str, key)
- fmt.Println(hms)
+ hms := cryptor.HmacSha1(str, key)
+ fmt.Println(hms)
- // Output:
- // 5c6a9db0cccb92e36ed0323fd09b7f936de9ace0
+ // Output:
+ // 5c6a9db0cccb92e36ed0323fd09b7f936de9ace0
}
```
### HmacSha256
@@ -805,13 +805,13 @@ import (
func main() {
str := "hello"
- key := "12345"
+ key := "12345"
- hms := cryptor.HmacSha256(str, key)
- fmt.Println(hms)
+ hms := cryptor.HmacSha256(str, key)
+ fmt.Println(hms)
- // Output:
- // 315bb93c4e989862ba09cb62e05d73a5f376cb36f0d786edab0c320d059fde75
+ // Output:
+ // 315bb93c4e989862ba09cb62e05d73a5f376cb36f0d786edab0c320d059fde75
}
```
@@ -837,13 +837,13 @@ import (
func main() {
str := "hello"
- key := "12345"
+ key := "12345"
- hms := cryptor.HmacSha512(str, key)
- fmt.Println(hms)
+ hms := cryptor.HmacSha512(str, key)
+ fmt.Println(hms)
- // Output:
- // dd8f1290a9dd23d354e2526d9a2e9ce8cffffdd37cb320800d1c6c13d2efc363288376a196c5458daf53f8e1aa6b45a6d856303d5c0a2064bff9785861d48cfc
+ // Output:
+ // dd8f1290a9dd23d354e2526d9a2e9ce8cffffdd37cb320800d1c6c13d2efc363288376a196c5458daf53f8e1aa6b45a6d856303d5c0a2064bff9785861d48cfc
}
```
@@ -871,11 +871,11 @@ import (
func main() {
str := "hello"
- md5Str := cryptor.Md5String(str)
- fmt.Println(md5Str)
+ md5Str := cryptor.Md5String(str)
+ fmt.Println(md5Str)
- // Output:
- // 5d41402abc4b2a76b9719d911017c592
+ // Output:
+ // 5d41402abc4b2a76b9719d911017c592
}
```
@@ -928,11 +928,11 @@ import (
func main() {
str := "hello"
- result := cryptor.Sha1(str)
- fmt.Println(result)
+ result := cryptor.Sha1(str)
+ fmt.Println(result)
- // Output:
- // aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
+ // Output:
+ // aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
}
```
@@ -959,11 +959,11 @@ import (
func main() {
str := "hello"
- result := cryptor.Sha256(str)
- fmt.Println(result)
+ result := cryptor.Sha256(str)
+ fmt.Println(result)
- // Output:
- // 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
+ // Output:
+ // 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
}
```
@@ -990,11 +990,11 @@ import (
func main() {
str := "hello"
- result := cryptor.Sha512(str)
- fmt.Println(result)
+ result := cryptor.Sha512(str)
+ fmt.Println(result)
- // Output:
- // 9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca72323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043
+ // Output:
+ // 9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca72323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043
}
```
@@ -1051,15 +1051,15 @@ func main() {
if err != nil {
return
}
-
+
data := []byte("hello")
encrypted := cryptor.RsaEncrypt(data, "rsa_public.pem")
decrypted := cryptor.RsaDecrypt(encrypted, "rsa_private.pem")
-
+
fmt.Println(string(decrypted))
// Output:
- // hello
+ // hello
}
```
@@ -1089,14 +1089,14 @@ func main() {
if err != nil {
return
}
-
+
data := []byte("hello")
encrypted := cryptor.RsaEncrypt(data, "rsa_public.pem")
decrypted := cryptor.RsaDecrypt(encrypted, "rsa_private.pem")
-
+
fmt.Println(string(decrypted))
// Output:
- // hello
+ // hello
}
```
\ No newline at end of file