Carlos Bello
Carlos Bello

Reputation: 262

parameter '*' in pycryptodome

Crypto.Cipher.<algorithm>.new(key, mode, *, nonce=None, mac_len=None)

Parameters:

key (bytes) – the cryptographic key

mode – the constant Crypto.Cipher.<algorithm>.MODE_GCM

nonce (bytes) – the value of the fixed nonce. It must be unique for the combination message/key. If not present, the library creates a random nonce (16 bytes long for AES).

mac_len (integer) – the desired length of the MAC tag, from 4 to 16 bytes (default: 16).

I have a question regarding the * parameter, since this is not explained in the documentation, what is that symbol? and what is it for in the method?

Upvotes: 0

Views: 53

Answers (1)

Green Cloak Guy
Green Cloak Guy

Reputation: 24691

* here doesn't refer to a parameter itself - rather, it's a division between the parameters before it (which can be specified positionally or as keywords), and the parameters after it (which are keyword-only, and cannot be specified positionally).

PEP 3102 goes into more detail.

Upvotes: 1

Related Questions