Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import nimcrypto
- import winim/clr
- # SharpKatz below
- let
- desiredResult: array[11, byte] = [byte 0x48,0x65,0x6c,0x6c,0x6f,0x20,0x77,0x6f,0x72,0x6c,0x64]
- cryptedInput: array[11, byte] = [byte 0x50,0x9d,0xaa,0xd5,0xdb,0xfc,0xc1,0x53,0xac,0xe2,0x27]
- cryptIV: array[16, byte] = [byte 0x11,0x65,0xde,0x9f,0xfe,0xc9,0x15,0x33,0x6e,0x0a,0x8a,0x2e,0x4a,0x2d,0xff,0xb7]
- cryptKey: array[16, byte] = [byte 0x50,0x61,0x4e,0x63,0x41,0x6b,0x33,0x73,0x5f,0x52,0x5f,0x54,0x34,0x73,0x54,0x79]
- func toByteSeq*(str: string): seq[byte] {.inline.} =
- @(str.toOpenArrayByte(0, str.high))
- var
- dctx: CTR[aes128]
- key : array[aes128.sizeKey, byte]
- iv : array[aes128.sizeBlock, byte]
- enctext = newSeq[byte](len(cryptedInput))
- dectext = newSeq[byte](len(cryptedInput))
- key = cryptKey
- iv = cryptIV
- copyMem(unsafeAddr enctext[0], unsafeAddr cryptedInput[0], len(cryptedInput))
- dctx.init(key, iv)
- dctx.decrypt(enctext, dectext)
- dctx.clear()
- doAssert dectext == desiredResult
- echo "DEBUG: Decryption success."
Advertisement
Add Comment
Please, Sign In to add comment