Guest User

Untitled

a guest
Jul 22nd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "crypto/aes"
  5. "sync"
  6. )
  7.  
  8. func main() {
  9. N := 10000
  10.  
  11. key := []byte{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c}
  12. in := []byte{0x32, 0x43, 0xf6, 0xa8, 0x88, 0x5a, 0x30, 0x8d, 0x31, 0x31, 0x98, 0xa2, 0xe0, 0x37, 0x07, 0x34}
  13. out := []byte{0x39, 0x25, 0x84, 0x1d, 0x02, 0xdc, 0x09, 0xfb, 0xdc, 0x11, 0x85, 0x97, 0x19, 0x6a, 0x0b, 0x32}
  14.  
  15. c, err := aes.NewCipher(key)
  16. if err != nil {
  17. panic(err)
  18. }
  19. wg := sync.WaitGroup{}
  20.  
  21. wg.Add(N)
  22. for j := 0; j < N; j++ {
  23. go func() {
  24. encrypted := make([]byte, len(in))
  25. c.Encrypt(encrypted, in)
  26. wg.Done()
  27. }()
  28. }
  29. wg.Wait()
  30.  
  31. wg.Add(N)
  32. for j := 0; j < N; j++ {
  33. go func() {
  34. decrypted := make([]byte, len(in))
  35. c.Decrypt(decrypted, out)
  36. wg.Done()
  37. }()
  38. }
  39. wg.Wait()
  40. }
Add Comment
Please, Sign In to add comment