### Install Nimcrypto Source: https://cheatfate.github.io/nimcrypto Use nimble to install the nimcrypto library. ```bash $ nimble install nimcrypto ``` -------------------------------- ### Get Key Size (Context) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/blowfish.html Template to get the key size of a Blowfish context. ```nim template sizeKey(ctx: BlowfishContext): int ``` -------------------------------- ### HMAC SHA256 Digest of Substring (Start) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/hmac.html Computes the HMAC SHA256 digest for a portion of a string, starting from a specified character index. The `ostart` parameter defines the start boundary (inclusive). ```nim let stringHmacKey = "AliceKey" let stringToHmac = "Hello World!" echo sha256.hmac(stringHmacKey, stringToHmac, ostart = 6) ``` -------------------------------- ### GETU32 Source: https://cheatfate.github.io/nimcrypto/nimcrypto/utils.html Template to get a uint32 from a memory address. ```APIDOC ## GETU32 ### Description Template to get a uint32 from a memory address. ### Method `template GETU32(p, o): uint32` ### Parameters - **p**: Pointer to the memory location. - **o**: Offset from the pointer. ``` -------------------------------- ### GETU64 Source: https://cheatfate.github.io/nimcrypto/nimcrypto/utils.html Template to get a uint64 from a memory address. ```APIDOC ## GETU64 ### Description Template to get a uint64 from a memory address. ### Method `template GETU64(p, o): uint64` ### Parameters - **p**: Pointer to the memory location. - **o**: Offset from the pointer. ``` -------------------------------- ### Get Key Size (Typedesc) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/blowfish.html Template to get the key size for the blowfish type. ```nim template sizeKey(r: typedesc[blowfish]): int ``` -------------------------------- ### EGETU32 Source: https://cheatfate.github.io/nimcrypto/nimcrypto/utils.html Template to get a uint32 from an encrypted memory address. ```APIDOC ## EGETU32 ### Description Template to get a uint32 from an encrypted memory address. ### Method `template EGETU32(p, o): uint32` ### Parameters - **p**: Pointer to the encrypted memory location. - **o**: Offset from the pointer. ``` -------------------------------- ### Get Block Size (Context) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/blowfish.html Template to get the block size of a Blowfish context. ```nim template sizeBlock(ctx: BlowfishContext): int ``` -------------------------------- ### Initialize ECB Context (openArray[byte]) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes the ECB context with an open array of bytes for the encryption key. No padding is performed on the key. The key length must be at least `ECB[T].sizeKey()` bytes. Refer to `examples/ecb.nim` for usage examples. ```nim proc init[T](ctx: var ECB[T]; key: openArray[byte]) {...}{.inline.} ``` -------------------------------- ### Get Key Size Template Source: https://cheatfate.github.io/nimcrypto/nimcrypto/twofish.html A template to retrieve the key size of a Twofish context. ```nim template sizeKey(ctx: TwofishContext): int ``` -------------------------------- ### GET_QWORD Source: https://cheatfate.github.io/nimcrypto/nimcrypto/utils.html Template to get a 64-bit quad word from a byte pointer. ```APIDOC ## GET_QWORD ### Description Template to get a 64-bit quad word from a byte pointer. ### Method `template GET_QWORD(p: ptr byte; i: int): uint64` ### Parameters - **p** (ptr byte) - Pointer to the byte array. - **i** (int) - The starting index. ``` -------------------------------- ### EGETU64 Source: https://cheatfate.github.io/nimcrypto/nimcrypto/utils.html Template to get a uint64 from an encrypted memory address. ```APIDOC ## EGETU64 ### Description Template to get a uint64 from an encrypted memory address. ### Method `template EGETU64(p, o): uint64` ### Parameters - **p**: Pointer to the encrypted memory location. - **o**: Offset from the pointer. ``` -------------------------------- ### Get RIPEMD Context Block Size Template Source: https://cheatfate.github.io/nimcrypto/nimcrypto/ripemd.html A template to get the block size used by a RIPEMD context. ```nim template sizeBlock(ctx: RipemdContext): uint ``` -------------------------------- ### Initialize ECB Context (openArray[char]) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes the ECB context with an open array of characters for the encryption key. No padding is performed on the key. The key length must be at least `ECB[T].sizeKey()` bytes. Refer to `examples/ecb.nim` for usage examples. ```nim proc init[T](ctx: var ECB[T]; key: openArray[char]) {...}{.inline.} ``` -------------------------------- ### GETU8 Source: https://cheatfate.github.io/nimcrypto/nimcrypto/utils.html Template to get a byte from a memory address. ```APIDOC ## GETU8 ### Description Template to get a byte from a memory address. ### Method `template GETU8(p, o): byte` ### Parameters - **p**: Pointer to the memory location. - **o**: Offset from the pointer. ``` -------------------------------- ### BLGETU64 Template Source: https://cheatfate.github.io/nimcrypto/nimcrypto/blake2.html Template for getting a 64-bit unsigned integer from a pointer offset. ```nim template BLGETU64(p, o): uint64 ``` -------------------------------- ### BLGETU32 Template Source: https://cheatfate.github.io/nimcrypto/nimcrypto/blake2.html Template for getting a 32-bit unsigned integer from a pointer offset. ```nim template BLGETU32(p, o): uint32 ``` -------------------------------- ### Get Block Size Template Source: https://cheatfate.github.io/nimcrypto/nimcrypto/twofish.html A template to retrieve the block size of a Twofish context. ```nim template sizeBlock(ctx: TwofishContext): int ``` -------------------------------- ### Template to Get Key Size from Context Source: https://cheatfate.github.io/nimcrypto/nimcrypto/rijndael.html Template `sizeKey` that returns the key size in bytes for a given `RijndaelContext`. ```nim template sizeKey(ctx: RijndaelContext): int ``` -------------------------------- ### Size Block Template for Blake2 Context Source: https://cheatfate.github.io/nimcrypto/nimcrypto/blake2.html Template to get the block size in bytes for a Blake2 context. ```nim template sizeBlock(ctx: Blake2Context): uint ``` -------------------------------- ### Size of Block for Keccak Context Template Source: https://cheatfate.github.io/nimcrypto/nimcrypto/keccak.html A template to get the block size for a given Keccak context. ```nim template sizeBlock(ctx: KeccakContext): uint ``` -------------------------------- ### Size Block Template for Blake2 Type Source: https://cheatfate.github.io/nimcrypto/nimcrypto/blake2.html Template to get the block size in bytes for a Blake2 type. ```nim template sizeBlock(r: typedesc[blake2]): int ``` -------------------------------- ### Basic Hashing with Keccak-256 Source: https://cheatfate.github.io/nimcrypto Demonstrates how to import the nimcrypto library and compute the Keccak-256 hash of a string. ```nim import nimcrypto echo keccak_256.digest("Alice makes a hash") # outputs F8AE86DA35CF3D9F0816BAA6015A6AFFD20BA5D6A533FEA94D89D6164264326F ``` -------------------------------- ### Size Digest Template for Blake2 Context Source: https://cheatfate.github.io/nimcrypto/nimcrypto/blake2.html Template to get the digest size in bytes for a Blake2 context. ```nim template sizeDigest(ctx: Blake2Context): uint ``` -------------------------------- ### Get Block Size (Typedesc) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/blowfish.html Template to get the block size for the blowfish type. ```nim template sizeBlock(r: typedesc[blowfish]): int ``` -------------------------------- ### init (context, key) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/rijndael.html Initializes the Rijndael context using a byte pointer for the key. An optional key length can be provided; if not specified, it defaults to 0. ```APIDOC ## init ### Description Initializes the Rijndael context using a byte pointer for the key. ### Parameters - **ctx** (var RijndaelContext) - The Rijndael context to initialize. - **key** (ptr byte) - A pointer to the byte array containing the encryption key. - **nkey** (int, optional) - The length of the key in bytes. Defaults to 0. ``` -------------------------------- ### init (context, openArray) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/rijndael.html Initializes the Rijndael context using an open array of bytes for the key. This is an inline procedure for convenience. ```APIDOC ## init ### Description Initializes the Rijndael context using an open array of bytes for the key. ### Parameters - **ctx** (var RijndaelContext) - The Rijndael context to initialize. - **key** (openArray[byte]) - An open array of bytes representing the encryption key. ``` -------------------------------- ### init (byte array) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/blowfish.html Initializes the Blowfish context with a given key represented as an open array of bytes. ```APIDOC ## init (byte array) ### Description Initializes the Blowfish context with the provided key. This overload accepts the key as an open array of bytes. ### Parameters * `ctx` (var BlowfishContext) - The Blowfish context to initialize. * `key` (openArray[byte]) - An open array of bytes representing the secret key. ``` -------------------------------- ### Size of Digest for Keccak Context Template Source: https://cheatfate.github.io/nimcrypto/nimcrypto/keccak.html A template to get the size of the digest for a given Keccak context. ```nim template sizeDigest(ctx: KeccakContext): uint ``` -------------------------------- ### Initialize OFB Mode with Pointers Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes the OFB[T] context using a key and IV provided as byte pointers. Ensure the key and IV meet the minimum size requirements. ```nim proc init[T](ctx: var OFB[T]; key: ptr byte; iv: ptr byte) ``` -------------------------------- ### Initialize Blowfish Context with Key (Pointer, Inline) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/blowfish.html Inline procedure to initialize the Blowfish context using a byte pointer key. ```nim proc init(ctx: var BlowfishContext; key: ptr byte; nkey: int) {...}{.inline.} ``` -------------------------------- ### Get RIPEMD Type Block Size Template Source: https://cheatfate.github.io/nimcrypto/nimcrypto/ripemd.html A template to get the block size for a specific RIPEMD type. ```nim template sizeBlock(r: typedesc[ripemd]): int ``` -------------------------------- ### Size Digest Template for Blake2 Type Source: https://cheatfate.github.io/nimcrypto/nimcrypto/blake2.html Template to get the digest size in bytes for a Blake2 type. ```nim template sizeDigest(r: typedesc[blake2]): int ``` -------------------------------- ### Get Key Size Template (Typedesc) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/twofish.html A template to retrieve the key size for a Twofish type descriptor. ```nim template sizeKey(r: typedesc[twofish]): int ``` -------------------------------- ### Initialize Blake2 Context with Key Source: https://cheatfate.github.io/nimcrypto/nimcrypto/blake2.html Initializes a Blake2 context, optionally with a secret key. The key is provided as a byte pointer and length. ```nim proc init(ctx: var Blake2Context; key: ptr byte = nil; keylen: uint = 0'u) ``` -------------------------------- ### Get RIPEMD Type Digest Size Template Source: https://cheatfate.github.io/nimcrypto/nimcrypto/ripemd.html A template to get the digest size for a specific RIPEMD type. ```nim template sizeDigest(r: typedesc[ripemd]): int ``` -------------------------------- ### Template to Get Block Size from Context Source: https://cheatfate.github.io/nimcrypto/nimcrypto/rijndael.html Template `sizeBlock` that returns the block size in bytes for a given `RijndaelContext`. ```nim template sizeBlock(ctx: RijndaelContext): int ``` -------------------------------- ### Size of Block for Keccak/Shake Types Template Source: https://cheatfate.github.io/nimcrypto/nimcrypto/keccak.html A template to get the block size for Keccak, Shake128, or Shake256 types. ```nim template sizeBlock(r: typedesc[keccak | shake128 | shake256]): int ``` -------------------------------- ### Initialize Rijndael Context with Key Pointer Source: https://cheatfate.github.io/nimcrypto/nimcrypto/rijndael.html Inline procedure to initialize a Rijndael context using a key pointer and an optional key size. Defaults to 0 if key size is not provided. ```nim proc init(ctx: var RijndaelContext; key: ptr byte; nkey: int = 0) {...}{.inline.} ``` -------------------------------- ### Get RIPEMD Context Digest Size Template Source: https://cheatfate.github.io/nimcrypto/nimcrypto/ripemd.html A template to get the size of the digest produced by a RIPEMD context. ```nim template sizeDigest(ctx: RipemdContext): uint ``` -------------------------------- ### Initialize CFB Context with Raw Pointers Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes the CFB[T] context with an encryption key and an initial vector (IV) using raw byte pointers. Key size must be at least ctx.sizeKey() and IV size at least ctx.sizeBlock(). ```nim proc init[T](ctx: var CFB[T]; key: ptr byte; iv: ptr byte) ``` -------------------------------- ### Initialize Keccak Context Procedure Source: https://cheatfate.github.io/nimcrypto/nimcrypto/keccak.html Initializes a Keccak context object. This should be called before updating the context with data. ```nim proc init(ctx: var KeccakContext) ``` -------------------------------- ### Initialize Blake2 Context with Key (OpenArray) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/blake2.html Initializes a Blake2 context with a secret key provided as an open array. This is an inline procedure. ```nim proc init[T: bchar](ctx: var Blake2Context; key: openArray[T]) {...}{.inline.} ``` -------------------------------- ### Initialize CBC Context with Pointers Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes a CBC[T] context using raw byte pointers for the key and initialization vector (IV). Ensure the key size is at least ctx.sizeKey and IV size is at least ctx.sizeBlock. ```nim proc init[T](ctx: var CBC[T]; key: ptr byte; iv: ptr byte) ``` -------------------------------- ### HMAC Initialization with String Key Source: https://cheatfate.github.io/nimcrypto/nimcrypto/hmac.html Initializes an HMAC context using a key provided as a string. The key can be of zero length. ```nim import nimcrypto/hmac let sha256 = newSHA256() var hctx = init(sha256) var key = "my secret key" hctx = init(sha256, key) # Or with an empty string: hctx = init(sha256, "") ``` -------------------------------- ### Get uint64 (QWORD) from Byte Pointer Source: https://cheatfate.github.io/nimcrypto/nimcrypto/utils.html Reads a uint64 (QWORD) value from a byte pointer at a specified index. Assumes little-endian format. ```nim template GET_QWORD(p: ptr byte; i: int): uint64 ``` -------------------------------- ### Template to Get Key Size for Rijndael Type Source: https://cheatfate.github.io/nimcrypto/nimcrypto/rijndael.html Template `sizeKey` that returns the key size in bytes for a typedesc of a Rijndael type (e.g., `rijndael128`). ```nim template sizeKey(r: typedesc[rijndael]): int ``` -------------------------------- ### Initialize Blowfish Context with Key (Pointer) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/blowfish.html Initializes the Blowfish context with a key provided as a byte pointer and its length. ```nim proc initBlowfishContext(ctx: var BlowfishContext; key: ptr byte; nkey: int) ``` -------------------------------- ### sizeBlockKeccakContext Source: https://cheatfate.github.io/nimcrypto/nimcrypto/keccak.html Gets the block size processed by a Keccak context. ```APIDOC ## sizeBlockKeccakContext ### Description Returns the block size in bytes that the Keccak context processes internally. ### Signature `template sizeBlock(ctx: KeccakContext): uint` ### Parameters * `ctx` (KeccakContext) - The Keccak context. ### Returns The block size in bytes. ``` -------------------------------- ### sizeDigestKeccakContext Source: https://cheatfate.github.io/nimcrypto/nimcrypto/keccak.html Gets the size of the digest produced by a Keccak context. ```APIDOC ## sizeDigestKeccakContext ### Description Returns the size in bytes of the digest that will be produced by the given Keccak context. ### Signature `template sizeDigest(ctx: KeccakContext): uint` ### Parameters * `ctx` (KeccakContext) - The Keccak context. ### Returns The digest size in bytes. ``` -------------------------------- ### Initialize CTR Mode with Pointers Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes the CTR[T] context using a key and IV provided as byte pointers. Ensure the key and IV meet the minimum size requirements. ```nim proc init[T](ctx: var CTR[T]; key: ptr byte; iv: ptr byte) ``` -------------------------------- ### Initialize Blowfish Context with Key (OpenArray) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/blowfish.html Inline procedure to initialize the Blowfish context using an open array of bytes as the key. ```nim proc init(ctx: var BlowfishContext; key: openArray[byte]) {...}{.inline.} ``` -------------------------------- ### GET_DWORD Source: https://cheatfate.github.io/nimcrypto/nimcrypto/utils.html Template to get a 32-bit double word from a byte pointer. ```APIDOC ## GET_DWORD ### Description Template to get a 32-bit double word from a byte pointer. ### Method `template GET_DWORD(p: ptr byte; i: int): uint32` ### Parameters - **p** (ptr byte) - Pointer to the byte array. - **i** (int) - The starting index. ``` -------------------------------- ### initRijndaelContext Source: https://cheatfate.github.io/nimcrypto/nimcrypto/rijndael.html Initializes a Rijndael context with a specified key size and the encryption key. This procedure is used to set up the context before performing encryption or decryption operations. ```APIDOC ## initRijndaelContext ### Description Initializes a Rijndael context with a specified key size and the encryption key. ### Parameters - **ctx** (var RijndaelContext) - The Rijndael context to initialize. - **N** (int) - The key size in bits (e.g., 128, 192, 256). - **key** (ptr byte) - A pointer to the byte array containing the encryption key. ``` -------------------------------- ### Initialize and Clear HMAC Context Source: https://cheatfate.github.io/nimcrypto/nimcrypto/hmac.html Demonstrates the initialization and clearing of HMAC contexts for subsequent update and finish operations. ```nim import nimcrypto/hmac let sha256 = newSHA256() var hctx1 = init(sha256) var hctx2 = init(sha256) # Example usage with update and finish would follow here... # Do not forget to clear contexts. hctx1.clear() hctx2.clear() ``` -------------------------------- ### sizeBlockkeccak Source: https://cheatfate.github.io/nimcrypto/nimcrypto/keccak.html Gets the fixed block size for a specific Keccak type. ```APIDOC ## sizeBlockkeccak ### Description Returns the block size in bytes for a given Keccak or SHAKE type. ### Signature `template sizeBlock(r: typedesc[keccak | shake128 | shake256]): int` ### Parameters * `r` (typedesc) - The type descriptor for a Keccak or SHAKE variant (e.g., `keccak256`, `shake128`). ### Returns The block size in bytes. ``` -------------------------------- ### sizeDigestkeccak Source: https://cheatfate.github.io/nimcrypto/nimcrypto/keccak.html Gets the fixed digest size for a specific Keccak type. ```APIDOC ## sizeDigestkeccak ### Description Returns the fixed digest size in bytes for a given Keccak or SHAKE type. ### Signature `template sizeDigest(r: typedesc[keccak | shake128 | shake256]): int` ### Parameters * `r` (typedesc) - The type descriptor for a Keccak or SHAKE variant (e.g., `keccak256`, `shake128`). ### Returns The digest size in bytes. ``` -------------------------------- ### Initialize Rijndael Context with Byte Array Source: https://cheatfate.github.io/nimcrypto/nimcrypto/rijndael.html Inline procedure to initialize a Rijndael context using an open array of bytes. ```nim proc init(ctx: var RijndaelContext; key: openArray[byte]) {...}{.inline.} ``` -------------------------------- ### Initialize OFB Mode with Byte Arrays Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes the OFB[T] context using byte arrays for the key and IV. No additional padding is performed, so ensure arrays meet minimum size requirements. ```nim proc init[T](ctx: var OFB[T]; key: openArray[byte]; iv: openArray[byte]) ``` -------------------------------- ### GCM Get Tag Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Retrieves the authentication tag generated during GCM encryption. ```APIDOC ## GCM Get Tag ### Description Retrieves the authentication tag generated during GCM encryption. ### Parameters - `ctx` (var GCM[T]): The GCM context. - `tag` (var openArray[byte]): The output array to store the authentication tag. ``` -------------------------------- ### Initialize CBC Context with Byte Arrays Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes a CBC[T] context using open arrays of bytes for the key and initialization vector (IV). The key length must be at least ctx.sizeKey() and the IV length at least ctx.sizeBlock(). ```nim proc init[T](ctx: var CBC[T]; key: openArray[byte]; iv: openArray[byte]) ``` -------------------------------- ### initKeccakContext Source: https://cheatfate.github.io/nimcrypto/nimcrypto/keccak.html Initializes a Keccak context for hashing operations. ```APIDOC ## initKeccakContext ### Description Initializes a Keccak context structure to prepare it for hashing. ### Signature `proc init(ctx: var KeccakContext)` ### Parameters * `ctx` (KeccakContext) - The Keccak context to initialize. ``` -------------------------------- ### Initialize Twofish Context (Pointer) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/twofish.html Initializes a Twofish context using a byte pointer and key length. This procedure is inlined. ```nim proc init(ctx: var TwofishContext; key: ptr byte; nkey: int = 0) {...}{.inline.} ``` -------------------------------- ### Initialize ECB Context (ptr byte) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes the ECB context with a raw byte pointer for the encryption key. Ensure the key data is at least `ctx.sizeKey` bytes. ```nim proc init[T](ctx: var ECB[T]; key: ptr byte) ``` -------------------------------- ### Size of Digest Template Source: https://cheatfate.github.io/nimcrypto/nimcrypto/sha2.html A template to get the size of the digest in bytes for a given SHA2 context. ```nim template sizeDigest(ctx: Sha2Context): uint ``` -------------------------------- ### Get GCM Key Size Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Returns the key size of the GCM cipher context in octets (bytes). ```nim template sizeKey[T](ctx: GCM[T]): int ``` -------------------------------- ### OFB Initialize (openArray[char]) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes an OFB context with a key and initialization vector (IV) using char arrays. ```APIDOC ## Initialize OFB (openArray[char]) ### Description Initializes an `OFB[T]` context with the provided encryption key and initialization vector (IV) using char open arrays. No additional padding is performed on the key or IV. ### Parameters - `ctx` (var OFB[T]): The OFB context to initialize. - `key` (openArray[char]): The encryption key. Must be at least `ctx.sizeKey()` bytes. - `iv` (openArray[char]): The initialization vector. Must be at least `ctx.sizeBlock()` bytes. ``` -------------------------------- ### Get GCM Block Size Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Returns the block size of the GCM cipher context in octets (bytes). ```nim template sizeBlock[T](ctx: GCM[T]): int ``` -------------------------------- ### OFB Initialize (openArray[byte]) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes an OFB context with a key and initialization vector (IV) using byte arrays. ```APIDOC ## Initialize OFB (openArray[byte]) ### Description Initializes an `OFB[T]` context with the provided encryption key and initialization vector (IV) using byte open arrays. No additional padding is performed on the key or IV. ### Parameters - `ctx` (var OFB[T]): The OFB context to initialize. - `key` (openArray[byte]): The encryption key. Must be at least `ctx.sizeKey()` bytes. - `iv` (openArray[byte]): The initialization vector. Must be at least `ctx.sizeBlock()` bytes. ``` -------------------------------- ### Get CFB Key Size Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Returns the key size of the CFB cipher context in octets (bytes). ```nim template sizeKey[T](ctx: CFB[T]): int ``` -------------------------------- ### CFB Initialization (Byte Arrays) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes a CFB[T] context with an encryption key and an initial vector (IV) using byte arrays. The key and IV lengths must meet minimum requirements. No additional padding is performed. ```APIDOC ## CFB Initialization (Byte Arrays) ### Description Initializes a `CFB[T]` context with an encryption key `key` and an initial vector (IV) `iv`. This procedure will not perform any additional padding for the encryption key `key` and initial vector `iv`. The length of the `key` array must be at least `ctx.sizeKey()` bytes. The length of the `iv` array must be at least `ctx.sizeBlock()` bytes. ### Parameters - **ctx** (var CFB[T]) - The CFB context to initialize. - **key** (openArray[byte]) - The encryption key as a byte array. - **iv** (openArray[byte]) - The initial vector as a byte array. ### See Also Examples of usage can be found in `examples/cfb.nim`. ``` -------------------------------- ### Get CFB Block Size Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Returns the block size of the CFB cipher context in octets (bytes). ```nim template sizeBlock[T](ctx: CFB[T]): int ``` -------------------------------- ### CFB Initialization (Pointers) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes a CFB[T] context with an encryption key and an initial vector (IV) using byte pointers. The key and IV must meet minimum length requirements. ```APIDOC ## CFB Initialization (Pointers) ### Description Initializes a `CFB[T]` context with an encryption key `key` and an initial vector (IV) `iv`. The size of the encryption key pointed to by `key` must be at least `ctx.sizeKey` bytes, and the size of the initial vector `iv` must be at least `ctx.sizeBlock` bytes. ### Parameters - **ctx** (var CFB[T]) - The CFB context to initialize. - **key** (ptr byte) - A pointer to the encryption key. - **iv** (ptr byte) - A pointer to the initial vector. ### See Also Examples of usage can be found in `examples/cfb.nim`. ``` -------------------------------- ### Get OFB Key Size Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Returns the key size of the OFB cipher context in octets (bytes). ```nim template sizeKey[T](ctx: OFB[T]): int ``` -------------------------------- ### Initialize RIPEMD Context Procedure Source: https://cheatfate.github.io/nimcrypto/nimcrypto/ripemd.html Initializes a RIPEMD context structure. This procedure is used to set up the context before hashing begins. ```nim proc init(ctx: var RipemdContext) ``` -------------------------------- ### Get OFB Block Size Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Returns the block size of the OFB cipher context in octets (bytes). ```nim template sizeBlock[T](ctx: OFB[T]): int ``` -------------------------------- ### Extendable Output Function (XOF) for Keccak Source: https://cheatfate.github.io/nimcrypto/nimcrypto/keccak.html Prepares the Keccak context for an extendable output function (XOF) operation, typically used with SHAKE. ```nim proc xof(ctx: var KeccakContext) ``` -------------------------------- ### CFB Initialization (Char Arrays) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes a CFB[T] context with an encryption key and an initial vector (IV) using character arrays. The key and IV lengths must meet minimum requirements. No additional padding is performed. ```APIDOC ## CFB Initialization (Char Arrays) ### Description Initializes a `CFB[T]` context with an encryption key `key` and an initial vector (IV) `iv`. This procedure will not perform any additional padding for the encryption key `key` and initial vector `iv`. The length of the `key` array must be at least `ctx.sizeKey()` bytes. The length of the `iv` array must be at least `ctx.sizeBlock()` bytes. ### Parameters - **ctx** (var CFB[T]) - The CFB context to initialize. - **key** (openArray[char]) - The encryption key as a character array. - **iv** (openArray[char]) - The initial vector as a character array. ### See Also Examples of usage can be found in `examples/cfb.nim`. ``` -------------------------------- ### Get CTR Key Size Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Returns the key size of the CTR cipher context in octets (bytes). ```nim template sizeKey[T](ctx: CTR[T]): int ``` -------------------------------- ### HMAC Initialization with Byte Array Key Source: https://cheatfate.github.io/nimcrypto/nimcrypto/hmac.html Initializes an HMAC context using a key provided as a byte array. The key can be of zero length. ```nim import nimcrypto/hmac let sha256 = newSHA256() var hctx = init(sha256) var key: openArray[byte] = @[byte(0x01), byte(0x02)] hctx = init(sha256, key) # Or with an empty key: hctx = init(sha256, @[]) ``` -------------------------------- ### Get CTR Block Size Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Returns the block size of the CTR cipher context in octets (bytes). ```nim template sizeBlock[T](ctx: CTR[T]): int ``` -------------------------------- ### Get CBC Key Size Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Returns the key size of the CBC cipher context in octets (bytes). ```nim template sizeKey[T](ctx: CBC[T]): int ``` -------------------------------- ### initBlowfishContext Source: https://cheatfate.github.io/nimcrypto/nimcrypto/blowfish.html Initializes the Blowfish context with a given key. ```APIDOC ## initBlowfishContext ### Description Initializes the Blowfish context with the provided key. This procedure sets up the internal state of the Blowfish algorithm based on the secret key. ### Parameters * `ctx` (var BlowfishContext) - The Blowfish context to initialize. * `key` (ptr byte) - A pointer to the byte array representing the secret key. * `nkey` (int) - The length of the key in bytes. ``` -------------------------------- ### Get CBC Block Size Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Returns the block size of the CBC cipher context in octets (bytes). ```nim template sizeBlock[T](ctx: CBC[T]): int ``` -------------------------------- ### Initialize SHA2 Context Procedure Source: https://cheatfate.github.io/nimcrypto/nimcrypto/sha2.html Initializes a SHA2 context structure. This procedure must be called before any other operations on the context. ```nim proc init(ctx: var Sha2Context) ``` -------------------------------- ### Get ECB Key Size Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Returns the key size of the ECB cipher context in octets (bytes). ```nim template sizeKey[T](ctx: ECB[T]): int ``` -------------------------------- ### Initialize CTR Mode with Byte Arrays Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes the CTR[T] context using byte arrays for the key and IV. No additional padding is performed, so ensure arrays meet minimum size requirements. ```nim proc init[T](ctx: var CTR[T]; key: openArray[byte]; iv: openArray[byte]) ``` -------------------------------- ### Get ECB Block Size Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Returns the block size of the ECB cipher context in octets (bytes). ```nim template sizeBlock[T](ctx: ECB[T]): int ``` -------------------------------- ### OFB Initialization Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes an OFB[T] context with an encryption key and an initial vector (IV). The key and IV lengths must meet minimum requirements. No additional padding is performed. ```APIDOC ## OFB Initialization ### Description Initializes an `OFB[T]` context with an encryption key `key` and an initial vector (IV) `iv`. This procedure does not perform any additional padding for the key and IV. The length of the `key` array must be at least `ctx.sizeKey()` bytes, and the length of the `iv` array must be at least `ctx.sizeBlock()` bytes. ### Parameters #### Path Parameters - **ctx** (var OFB[T]) - The OFB context to initialize. - **key** (ptr byte) - A pointer to the encryption key. - **iv** (ptr byte) - A pointer to the initial vector. ### See Also Examples of usage can be found in `examples/ofb.nim`. ``` -------------------------------- ### CTR Initialize (openArray[byte]) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes a CTR context with a key and initialization vector (IV) using byte arrays. ```APIDOC ## Initialize CTR (openArray[byte]) ### Description Initializes a `CTR[T]` context with the provided encryption key and initialization vector (IV) using byte open arrays. No additional padding is performed on the key or IV. ### Parameters - `ctx` (var CTR[T]): The CTR context to initialize. - `key` (openArray[byte]): The encryption key. Must be at least `ctx.sizeKey()` bytes. - `iv` (openArray[byte]): The initialization vector. Must be at least `ctx.sizeBlock()` bytes. ``` -------------------------------- ### Initialize CBC Context with Char Arrays Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes a CBC[T] context using open arrays of characters for the key and initialization vector (IV). The key length must be at least ctx.sizeKey() and the IV length at least ctx.sizeBlock(). ```nim proc init[T](ctx: var CBC[T]; key: openArray[char]; iv: openArray[char]) ``` -------------------------------- ### OFB Initialize (ptr) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes an OFB context with a key and initialization vector (IV) using pointers. ```APIDOC ## Initialize OFB (ptr) ### Description Initializes an `OFB[T]` context with the provided encryption key and initialization vector (IV) using pointers. ### Parameters - `ctx` (var OFB[T]): The OFB context to initialize. - `key` (ptr byte): A pointer to the encryption key. Must be at least `ctx.sizeKey` bytes. - `iv` (ptr byte): A pointer to the initialization vector. Must be at least `ctx.sizeBlock` bytes. ``` -------------------------------- ### Initialize Twofish Context (OpenArray) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/twofish.html Initializes a Twofish context using an open array of bytes. This procedure is inlined. ```nim proc init(ctx: var TwofishContext; key: openArray[byte]) {...}{.inline.} ``` -------------------------------- ### Initialize OFB Mode with Char Arrays Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes the OFB[T] context using character arrays for the key and IV. No additional padding is performed, so ensure arrays meet minimum size requirements. ```nim proc init[T](ctx: var OFB[T]; key: openArray[char]; iv: openArray[char]) ``` -------------------------------- ### CTR Initialize (openArray[char]) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes a CTR context with a key and initialization vector (IV) using char arrays. ```APIDOC ## Initialize CTR (openArray[char]) ### Description Initializes a `CTR[T]` context with the provided encryption key and initialization vector (IV) using char open arrays. No additional padding is performed on the key or IV. ### Parameters - `ctx` (var CTR[T]): The CTR context to initialize. - `key` (openArray[char]): The encryption key. Must be at least `ctx.sizeKey()` bytes. - `iv` (openArray[char]): The initialization vector. Must be at least `ctx.sizeBlock()` bytes. ``` -------------------------------- ### Get Block Size Template (Typedesc) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/twofish.html A template to retrieve the block size for a Twofish type descriptor. ```nim template sizeBlock(r: typedesc[twofish]): int ``` -------------------------------- ### HMAC Context Initialization Source: https://cheatfate.github.io/nimcrypto/nimcrypto/hmac.html Initializes an HMAC context with a given key. The key can be provided as a byte pointer and length, or as a byte array or string. ```APIDOC ## HMAC Context Initialization ### Procedures ```nim proc init[T](hmctx: var HMAC[T]; key: ptr byte; ulen: uint) ``` Initialize HMAC context `hmctx` with key using `key` and size `ulen`. `key` can be `nil`. ```nim proc init[T](hmctx: var HMAC[T]; key: openArray[byte]) ``` Initialize HMAC context `hmctx` with key using `key` array. `key` can be zero-length array. ```nim proc init[T](hmctx: var HMAC[T]; key: openArray[char]) ``` Initialize HMAC context `hmctx` with key using `key` string/array. `key` can be zero-length array. ``` -------------------------------- ### Initialize CFB Context with OpenArray Char Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes the CFB[T] context with an encryption key and an initial vector (IV) using an openArray of chars. Key length must be at least ctx.sizeKey() and IV length at least ctx.sizeBlock(). No additional padding is performed. ```nim proc init[T](ctx: var CFB[T]; key: openArray[char]; iv: openArray[char]) ``` -------------------------------- ### Initialize CFB Context with OpenArray Byte Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes the CFB[T] context with an encryption key and an initial vector (IV) using an openArray of bytes. Key length must be at least ctx.sizeKey() and IV length at least ctx.sizeBlock(). No additional padding is performed. ```nim proc init[T](ctx: var CFB[T]; key: openArray[byte]; iv: openArray[byte]) ``` -------------------------------- ### Classic HMAC Calculation with SHA256 Source: https://cheatfate.github.io/nimcrypto/nimcrypto/hmac.html Demonstrates the classic method for HMAC calculation using SHA256. Initializes HMAC contexts with string and pointer keys, then updates them with string and pointer data. Requires importing the nimcrypto module. ```nim import nimcrypto var stringToHmac = "Hello World!" var stringHmacKey = "AliceKey" let ptrToHmac = cast[ptr byte](addr stringToHmac[0]) let ptrHmacKey = cast[ptr byte](addr stringHmacKey[0]) let toHmacLen = uint(len(stringToHmac)) let hmacKeyLen = uint(len(stringHmacKey)) # Declare context objects var hctx1, hctx2: HMAC[sha256] # Initalize HMAC[SHA256] contexts with key `AliceKey`. hctx1.init(stringHmacKey) hctx2.init(ptrHmacKey, hmacKeyLen) # Update HMAC[SHA256] context using data `Hello World!` twice. hctx1.update(stringToHmac) hctx1.update(stringToHmac) # Update HMAC[SHA256] context using data `Hello World!` twice. hctx2.update(ptrToHmac, toHmacLen) hctx2.update(ptrToHmac, toHmacLen) ``` -------------------------------- ### Size of Digest for Keccak/Shake Types Template Source: https://cheatfate.github.io/nimcrypto/nimcrypto/keccak.html A template to get the digest size for Keccak, Shake128, or Shake256 types. ```nim template sizeDigest(r: typedesc[keccak | shake128 | shake256]): int ``` -------------------------------- ### CTR Initialize (ptr) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes a CTR context with a key and initialization vector (IV) using pointers. ```APIDOC ## Initialize CTR (ptr) ### Description Initializes a `CTR[T]` context with the provided encryption key and initialization vector (IV) using pointers. ### Parameters - `ctx` (var CTR[T]): The CTR context to initialize. - `key` (ptr byte): A pointer to the encryption key. Must be at least `ctx.sizeKey` bytes. - `iv` (ptr byte): A pointer to the initialization vector. Must be at least `ctx.sizeBlock` bytes. ``` -------------------------------- ### Size of Block Template Source: https://cheatfate.github.io/nimcrypto/nimcrypto/sha2.html A template to get the size of the internal block buffer in bytes for a given SHA2 context. ```nim template sizeBlock(ctx: Sha2Context): uint ``` -------------------------------- ### PUTU32 Source: https://cheatfate.github.io/nimcrypto/nimcrypto/utils.html Template to put a uint32 to a memory address. ```APIDOC ## PUTU32 ### Description Template to put a uint32 to a memory address. ### Method `template PUTU32(p, o, v)` ### Parameters - **p**: Pointer to the memory location. - **o**: Offset from the pointer. - **v**: The uint32 value to put. ``` -------------------------------- ### Get GCM Authentication Tag Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Obtains the authentication tag from a GCM context. The maximum tag size is 16 bytes. ```nim proc getTag[T](ctx: var GCM[T]): array[16, byte] {...}{.noinit.} ``` -------------------------------- ### BLAKE2 Context Operations Source: https://cheatfate.github.io/nimcrypto/nimcrypto/blake2.html This section details the procedures for managing the BLAKE2 hashing context, including initialization, updating with data, and finalizing the hash computation. ```APIDOC ## `initBlake2Context` ### Description Initializes a BLAKE2 context for hashing. It can optionally take a key for keyed hashing. ### Signature ```nim proc init(ctx: var Blake2Context; key: ptr byte = nil; keylen: uint = 0'u) proc init[T: bchar](ctx: var Blake2Context; key: openArray[T]) ``` ## `updateBlake2Context` ### Description Updates the BLAKE2 context with new data. This can be called multiple times to hash large amounts of data incrementally. ### Signature ```nim proc update(ctx: var Blake2Context; data: ptr byte; ulen: uint) proc update[T: bchar](ctx: var Blake2Context; data: openArray[T]) ``` ## `finishBlake2Context` ### Description Finalizes the BLAKE2 hash computation and returns the resulting digest. There are multiple overloads for different context types and output methods. ### Signature ```nim proc finish(ctx: var Blake2sContext; data: ptr byte; ulen: uint): uint proc finish(ctx: var Blake2bContext; data: ptr byte; ulen: uint): uint proc finish(ctx: var Blake2sContext): MDigest[ctx.bits] proc finish(ctx: var Blake2bContext): MDigest[ctx.bits] proc finish[T: bchar](ctx: var Blake2Context; data: var openArray[T]) ``` ## `clearBlake2Context` ### Description Clears and resets the BLAKE2 context, making it ready for reuse or ensuring sensitive state is zeroed out. ### Signature ```nim proc clear(ctx: var Blake2Context) ``` ``` -------------------------------- ### Get uint64 from Byte Sequence Source: https://cheatfate.github.io/nimcrypto/nimcrypto/utils.html Reads a uint64 value from a byte sequence at a specified offset. Assumes little-endian format. ```nim template GETU64(p, o): uint64 ``` -------------------------------- ### Initialize Rijndael Context Procedure Signature Source: https://cheatfate.github.io/nimcrypto/nimcrypto/rijndael.html Declares the procedure signature for `initRijndaelContext`, used to initialize a Rijndael context with a specified key size and key material. ```nim proc initRijndaelContext(ctx: var RijndaelContext; N: int; key: ptr byte) ``` -------------------------------- ### Get uint32 from Byte Sequence Source: https://cheatfate.github.io/nimcrypto/nimcrypto/utils.html Reads a uint32 value from a byte sequence at a specified offset. Assumes little-endian format. ```nim template GETU32(p, o): uint32 ``` -------------------------------- ### ECB Initialization Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes the ECB (Electronic Code Book) context with an encryption key. The key must be at least `ctx.sizeKey` bytes. Overloads are provided for `ptr byte`, `openArray[byte]`, and `openArray[char]` keys. ```APIDOC ## proc init[T](ctx: var ECB[T]; key: ptr byte) ### Description Initializes the `ECB[T]` context with the provided encryption key. ### Parameters * `ctx` (var ECB[T]): The ECB context to initialize. * `key` (ptr byte): A pointer to the encryption key. The data pointed to must be at least `ctx.sizeKey` bytes. ### Returns None ``` ```APIDOC ## proc init[T](ctx: var ECB[T]; key: openArray[byte]) ### Description Initializes the `ECB[T]` context with the provided encryption key. This procedure does not perform any additional padding for the key. The length of `key` must be at least `ECB[T].sizeKey()` bytes. Examples of usage can be found in `examples/ecb.nim`. ### Parameters * `ctx` (var ECB[T]): The ECB context to initialize. * `key` (openArray[byte]): An open array of bytes representing the encryption key. ### Returns None ``` ```APIDOC ## proc init[T](ctx: var ECB[T]; key: openArray[char]) ### Description Initializes the `ECB[T]` context with the provided encryption key. This procedure does not perform any additional padding for the key. The length of `key` must be at least `ECB[T].sizeKey()` bytes. Examples of usage can be found in `examples/ecb.nim`. ### Parameters * `ctx` (var ECB[T]): The ECB context to initialize. * `key` (openArray[char]): An open array of characters representing the encryption key. ### Returns None ``` -------------------------------- ### Get GCM Authentication Tag Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Retrieves the authentication tag generated during GCM encryption. The tag is stored in the 'tag' output parameter. ```nim proc getTag[T](ctx: var GCM[T]; tag: var openArray[byte]) ``` -------------------------------- ### Size of Digest Template for SHA2 Type Source: https://cheatfate.github.io/nimcrypto/nimcrypto/sha2.html A template to get the size of the digest in bytes for a specified SHA2 type (e.g., sha256). ```nim template sizeDigest(r: typedesc[sha2]): int ``` -------------------------------- ### Finish Blake2s Context Hashing (MDigest Output) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/blake2.html Finalizes the BLAKE2s hashing process and returns the resulting hash as an MDigest of the context's bit size. ```nim proc finish(ctx: var Blake2sContext): MDigest[ctx.bits] ``` -------------------------------- ### Get byte (uint8) from Byte Sequence Source: https://cheatfate.github.io/nimcrypto/nimcrypto/utils.html Reads a single byte (uint8) from a byte sequence at a specified offset. Assumes little-endian format. ```nim template GETU8(p, o): byte ``` -------------------------------- ### Finish Blake2b Context Hashing (MDigest Output) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/blake2.html Finalizes the BLAKE2b hashing process and returns the resulting hash as an MDigest of the context's bit size. ```nim proc finish(ctx: var Blake2bContext): MDigest[ctx.bits] ``` -------------------------------- ### Get uint32 (DWORD) from Byte Pointer Source: https://cheatfate.github.io/nimcrypto/nimcrypto/utils.html Reads a uint32 (DWORD) value from a byte pointer at a specified index. Assumes little-endian format. ```nim template GET_DWORD(p: ptr byte; i: int): uint32 ``` -------------------------------- ### RipemdContext Initialization Source: https://cheatfate.github.io/nimcrypto/nimcrypto/ripemd.html Initializes a RipemdContext for hashing. This prepares the context for processing data. ```APIDOC ## initRipemdContext ### Description Initializes a RipemdContext for hashing. This prepares the context for processing data. ### Signature ```nim proc init(ctx: var RipemdContext) ``` ``` -------------------------------- ### Get uint64 from Encrypted Byte Sequence Source: https://cheatfate.github.io/nimcrypto/nimcrypto/utils.html Reads a uint64 value from an encrypted byte sequence at a specified offset. Assumes little-endian format. ```nim template EGETU64(p, o): uint64 ``` -------------------------------- ### initSha2Context Source: https://cheatfate.github.io/nimcrypto/nimcrypto/sha2.html Initializes a SHA2 context structure. This must be called before any other operations on the context. ```APIDOC ## initSha2Context ### Description Initializes a SHA2 context structure. This must be called before any other operations on the context. ### Signature `proc init(ctx: var Sha2Context)` ### Parameters - **ctx** (var Sha2Context): The SHA2 context to initialize. ``` -------------------------------- ### Get uint32 from Encrypted Byte Sequence Source: https://cheatfate.github.io/nimcrypto/nimcrypto/utils.html Reads a uint32 value from an encrypted byte sequence at a specified offset. Assumes little-endian format. ```nim template EGETU32(p, o): uint32 ``` -------------------------------- ### Template to Get Block Size for Rijndael Type Source: https://cheatfate.github.io/nimcrypto/nimcrypto/rijndael.html Template `sizeBlock` that returns the block size in bytes for a typedesc of a Rijndael type (e.g., `rijndael128`). ```nim template sizeBlock(r: typedesc[rijndael]): int ``` -------------------------------- ### Finish Blake2 Context Hashing (OpenArray Output) Source: https://cheatfate.github.io/nimcrypto/nimcrypto/blake2.html Finalizes the BLAKE2 hashing process and writes the resulting hash into a provided open array. This is an inline procedure. ```nim proc finish[T: bchar](ctx: var Blake2Context; data: var openArray[T]) ``` -------------------------------- ### Size of Block Template for SHA2 Type Source: https://cheatfate.github.io/nimcrypto/nimcrypto/sha2.html A template to get the size of the internal block buffer in bytes for a specified SHA2 type (e.g., sha256). ```nim template sizeBlock(r: typedesc[sha2]): int ``` -------------------------------- ### Initialize CTR Mode with Char Arrays Source: https://cheatfate.github.io/nimcrypto/nimcrypto/bcmode.html Initializes the CTR[T] context using character arrays for the key and IV. No additional padding is performed, so ensure arrays meet minimum size requirements. ```nim proc init[T](ctx: var CTR[T]; key: openArray[char]; iv: openArray[char]) {...}{.inline.} ```