Guest User

crash.nim

a guest
Jan 10th, 2021
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 1.03 KB | None | 0 0
  1. import nimcrypto
  2. import winim/clr
  3.  
  4. # SharpKatz below
  5. let
  6.     desiredResult: array[11, byte] = [byte 0x48,0x65,0x6c,0x6c,0x6f,0x20,0x77,0x6f,0x72,0x6c,0x64]
  7.     cryptedInput: array[11, byte] = [byte 0x50,0x9d,0xaa,0xd5,0xdb,0xfc,0xc1,0x53,0xac,0xe2,0x27]
  8.     cryptIV: array[16, byte] = [byte 0x11,0x65,0xde,0x9f,0xfe,0xc9,0x15,0x33,0x6e,0x0a,0x8a,0x2e,0x4a,0x2d,0xff,0xb7]
  9.     cryptKey: array[16, byte] = [byte 0x50,0x61,0x4e,0x63,0x41,0x6b,0x33,0x73,0x5f,0x52,0x5f,0x54,0x34,0x73,0x54,0x79]
  10.  
  11.  
  12. func toByteSeq*(str: string): seq[byte] {.inline.} =
  13.   @(str.toOpenArrayByte(0, str.high))
  14.  
  15. var
  16.     dctx: CTR[aes128]
  17.     key : array[aes128.sizeKey, byte]
  18.     iv : array[aes128.sizeBlock, byte]
  19.     enctext = newSeq[byte](len(cryptedInput))
  20.     dectext = newSeq[byte](len(cryptedInput))
  21.  
  22. key = cryptKey
  23. iv = cryptIV
  24.  
  25. copyMem(unsafeAddr enctext[0], unsafeAddr cryptedInput[0], len(cryptedInput))
  26.  
  27. dctx.init(key, iv)
  28. dctx.decrypt(enctext, dectext)
  29. dctx.clear()
  30.  
  31. doAssert dectext == desiredResult
  32. echo "DEBUG: Decryption success."
Advertisement
Add Comment
Please, Sign In to add comment