-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
46 lines (33 loc) · 802 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"fmt"
x "github.com/aaomidi/go-rc4/rc4"
)
func main() {
test1()
test2()
}
func test1() {
c1 := x.NewCipher([]byte{0x1A, 0x2B, 0x3C, 0x4D, 0x5E, 0x6F, 0x77})
c2 := x.NewCipher([]byte{0x1A, 0x2B, 0x3C, 0x4D, 0x5E, 0x6F, 0x77})
msg := []byte("Hey this is Amir")
// Get rid of the problematic 256 bytes
c1.StepRounds(256)
c2.StepRounds(256)
encrypted := make([]byte, len(msg))
decrypted := make([]byte, len(msg))
c1.Apply(encrypted, msg)
c2.Apply(decrypted, encrypted)
fmt.Println(string(decrypted))
}
func test2() {
c := x.NewCipher([]byte{0x1A, 0x2B, 0x3C, 0x4D, 0x5E, 0x6F, 0x77})
fmt.Println("Round 0:")
c.PrintReport()
fmt.Println("Round 100:")
c.StepRounds(100)
c.PrintReport()
fmt.Println("Round 1000:")
c.StepRounds(900)
c.PrintReport()
}