_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q32200
get_sci_segs_for_ifo
train
def get_sci_segs_for_ifo(ifo, cp, start_time, end_time, out_dir, tags=None): """ Obtain science segments for the selected ifo Parameters ----------- ifo : string The string describing the ifo to obtain science times for. start_time : gps time (either int/LIGOTimeGPS) The time at...
python
{ "resource": "" }
q32201
get_veto_segs
train
def get_veto_segs(workflow, ifo, category, start_time, end_time, out_dir, veto_gen_job, tags=None, execute_now=False): """ Obtain veto segments for the selected ifo and veto category and add the job to generate this to the workflow. Parameters ----------- workflow: pycbc.workf...
python
{ "resource": "" }
q32202
create_segs_from_cats_job
train
def create_segs_from_cats_job(cp, out_dir, ifo_string, tags=None): """ This function creates the CondorDAGJob that will be used to run ligolw_segments_from_cats as part of the workflow Parameters ----------- cp : pycbc.workflow.configuration.WorkflowConfigParser The in-memory representa...
python
{ "resource": "" }
q32203
get_cumulative_segs
train
def get_cumulative_segs(workflow, categories, seg_files_list, out_dir, tags=None, execute_now=False, segment_name=None): """ Function to generate one of the cumulative, multi-detector segment files as part of the workflow. Parameters ----------- workflow: pycbc.workflow....
python
{ "resource": "" }
q32204
add_cumulative_files
train
def add_cumulative_files(workflow, output_file, input_files, out_dir, execute_now=False, tags=None): """ Function to combine a set of segment files into a single one. This function will not merge the segment lists but keep each separate. Parameters ----------- workflow:...
python
{ "resource": "" }
q32205
find_playground_segments
train
def find_playground_segments(segs): '''Finds playground time in a list of segments. Playground segments include the first 600s of every 6370s stride starting at GPS time 729273613. Parameters ---------- segs : segmentfilelist A segmentfilelist to find playground segments. ...
python
{ "resource": "" }
q32206
save_veto_definer
train
def save_veto_definer(cp, out_dir, tags=None): """ Retrieve the veto definer file and save it locally Parameters ----------- cp : ConfigParser instance out_dir : path tags : list of strings Used to retrieve subsections of the ini file for configuration options. """ if ta...
python
{ "resource": "" }
q32207
parse_cat_ini_opt
train
def parse_cat_ini_opt(cat_str): """ Parse a cat str from the ini file into a list of sets """ if cat_str == "": return [] cat_groups = cat_str.split(',') cat_sets = []
python
{ "resource": "" }
q32208
file_needs_generating
train
def file_needs_generating(file_path, cp, tags=None): """ This job tests the file location and determines if the file should be generated now or if an error should be raised. This uses the generate_segment_files variable, global to this module, which is described above and in the documentation. ...
python
{ "resource": "" }
q32209
get_segments_file
train
def get_segments_file(workflow, name, option_name, out_dir): """Get cumulative segments from option name syntax for each ifo. Use syntax of configparser string to define the resulting segment_file e.x. option_name = +up_flag1,+up_flag2,+up_flag3,-down_flag1,-down_flag2 Each ifo may have a different str...
python
{ "resource": "" }
q32210
get_swstat_bits
train
def get_swstat_bits(frame_filenames, swstat_channel_name, start_time, end_time): ''' This function just checks the first time in the SWSTAT channel to see if the filter was on, it doesn't check times beyond that. This is just for a first test on a small chunck of data. To read the SWSTAT bits, referen...
python
{ "resource": "" }
q32211
filter_data
train
def filter_data(data, filter_name, filter_file, bits, filterbank_off=False, swstat_channel_name=None): ''' A naive function to determine if the filter was on at the time and then filter the data. ''' # if filterbank is off then return a time series of zeroes if filterbank_of...
python
{ "resource": "" }
q32212
read_gain_from_frames
train
def read_gain_from_frames(frame_filenames, gain_channel_name, start_time, end_time): ''' Returns the gain from the file. ''' # get timeseries from frame
python
{ "resource": "" }
q32213
load_from_config
train
def load_from_config(cp, model, **kwargs): """Loads a sampler from the given config file. This looks for a name in the section ``[sampler]`` to determine which sampler class to load. That sampler's ``from_config`` is then called. Parameters ---------- cp : WorkflowConfigParser Config p...
python
{ "resource": "" }
q32214
qplane
train
def qplane(qplane_tile_dict, fseries, return_complex=False): """Performs q-transform on each tile for each q-plane and selects tile with the maximum energy. Q-transform can then be interpolated to a desired frequency and time resolution. Parameters ---------- qplane_tile_dict: Dic...
python
{ "resource": "" }
q32215
qtiling
train
def qtiling(fseries, qrange, frange, mismatch=0.2): """Iterable constructor of QTile tuples Parameters ---------- fseries: 'pycbc FrequencySeries' frequency-series data set qrange: upper and lower bounds of q range frange: upper and lower bounds of frequency range
python
{ "resource": "" }
q32216
get_build_name
train
def get_build_name(git_path='git'): """Find the username of the current builder """ name,retcode = call(('git', 'config', 'user.name'), returncode=True) if retcode: name = "Unknown
python
{ "resource": "" }
q32217
get_last_commit
train
def get_last_commit(git_path='git'): """Returns the details of the last git commit Returns a tuple (hash, date, author name, author e-mail, committer name, committer e-mail). """ hash_, udate, aname, amail, cname, cmail = ( call((git_path, 'log', '-1', '--pretty=format:%H,%ct,...
python
{ "resource": "" }
q32218
get_git_branch
train
def get_git_branch(git_path='git'): """Returns the name of the current git branch """ branch_match = call((git_path, 'rev-parse', '--symbolic-full-name', 'HEAD')) if
python
{ "resource": "" }
q32219
get_git_tag
train
def get_git_tag(hash_, git_path='git'): """Returns the name of the current git tag """ tag, status = call((git_path, 'describe', '--exact-match',
python
{ "resource": "" }
q32220
get_git_status
train
def get_git_status(git_path='git'): """Returns the state of the git working copy """ status_output = subprocess.call((git_path, 'diff-files', '--quiet')) if status_output != 0: return 'UNCLEAN: Modified working tree'
python
{ "resource": "" }
q32221
generate_git_version_info
train
def generate_git_version_info(): """Query the git repository information to generate a version module. """ info = GitInfo() git_path = call(('which', 'git')) # get build info info.builder = get_build_name() info.build_date = get_build_date() # parse git ID info.hash, info.date, inf...
python
{ "resource": "" }
q32222
SingleDetSGChisq.values
train
def values(self, stilde, template, psd, snrv, snr_norm, bchisq, bchisq_dof, indices): """ Calculate sine-Gaussian chisq Parameters ---------- stilde: pycbc.types.Frequencyseries The overwhitened strain template: pycbc.types.Frequencyseries ...
python
{ "resource": "" }
q32223
PhaseTDStatistic.logsignalrate
train
def logsignalrate(self, s0, s1, slide, step): """Calculate the normalized log rate density of signals via lookup""" td = numpy.array(s0['end_time'] - s1['end_time'] - slide*step, ndmin=1) pd = numpy.array((s0['coa_phase'] - s1['coa_phase']) % \ (2. * numpy.pi), ndmin=1) ...
python
{ "resource": "" }
q32224
ExpFitStatistic.lognoiserate
train
def lognoiserate(self, trigs): """ Calculate the log noise rate density over single-ifo newsnr Read in single trigger information, make the newsnr statistic and rescale by the fitted coefficients alpha and rate """ alphai, ratei, thresh = self.find_fits(trigs) ne...
python
{ "resource": "" }
q32225
ExpFitStatistic.coinc
train
def coinc(self, s0, s1, slide, step): # pylint:disable=unused-argument """Calculate the final coinc ranking statistic""" # Approximate log likelihood ratio by summing single-ifo negative # log noise likelihoods loglr = - s0 - s1 # add squares of threshold stat values via idealize...
python
{ "resource": "" }
q32226
TenantMixin._drop_schema
train
def _drop_schema(self, force_drop=False): """ Drops the schema""" connection = connections[get_tenant_database_alias()] has_schema = hasattr(connection, 'schema_name') if has_schema and connection.schema_name not in (self.schema_name, get_public_schema_name()): raise Exceptio...
python
{ "resource": "" }
q32227
TenantMixin.get_primary_domain
train
def get_primary_domain(self): """ Returns the primary domain of the tenant """ try: domain = self.domains.get(is_primary=True)
python
{ "resource": "" }
q32228
TenantMixin.reverse
train
def reverse(self, request, view_name): """ Returns the URL of this tenant. """ http_type = 'https://' if request.is_secure() else 'http://' domain = get_current_site(request).domain
python
{ "resource": "" }
q32229
TenantSyncRouter.app_in_list
train
def app_in_list(self, app_label, apps_list): """ Is 'app_label' present in 'apps_list'? apps_list is either settings.SHARED_APPS or settings.TENANT_APPS, a list of app names. We check the presence of the app's name or the full path to the apps's AppConfig class. ...
python
{ "resource": "" }
q32230
TenantFileSystemFinder.check
train
def check(self, **kwargs): """ In addition to parent class' checks, also ensure that MULTITENANT_STATICFILES_DIRS is a tuple or a list. """ errors = super().check(**kwargs) multitenant_staticfiles_dirs = settings.MULTITENANT_STATICFILES_DIRS
python
{ "resource": "" }
q32231
DatabaseWrapper.set_schema_to_public
train
def set_schema_to_public(self): """ Instructs to stay in the common 'public' schema. """ self.tenant = FakeTenant(schema_name=get_public_schema_name())
python
{ "resource": "" }
q32232
Loader.cache_key
train
def cache_key(self, template_name, skip=None): """ Generate a cache key for the template name, dirs, and skip. If skip is provided, only origins that match template_name are included in the cache key. This ensures each template is only parsed and cached once if contained in diff...
python
{ "resource": "" }
q32233
parse_tenant_config_path
train
def parse_tenant_config_path(config_path): """ Convenience function for parsing django-tenants' path configuration strings. If the string contains '%s', then the current tenant's schema name will be inserted at that location. Otherwise the schema name will be appended to the end of the string. :pa...
python
{ "resource": "" }
q32234
CloneSchema._create_clone_schema_function
train
def _create_clone_schema_function(self): """ Creates a postgres function `clone_schema` that copies a schema and its contents. Will replace any existing `clone_schema` functions owned by the `postgres`
python
{ "resource": "" }
q32235
CloneSchema.clone_schema
train
def clone_schema(self, base_schema_name, new_schema_name): """ Creates a new schema `new_schema_name` as a clone of an existing schema `old_schema_name`. """ connection.set_schema_to_public() cursor = connection.cursor() # check if the clone_schema function alrea...
python
{ "resource": "" }
q32236
install_database
train
def install_database(name, owner, template='template0', encoding='UTF8', locale='en_US.UTF-8'): """ Require a PostgreSQL database. ::
python
{ "resource": "" }
q32237
ECSTransformer.add_volume
train
def add_volume(self, volume): """ Add a volume to self.volumes if it isn't already present
python
{ "resource": "" }
q32238
ECSTransformer.emit_containers
train
def emit_containers(self, containers, verbose=True): """ Emits the task definition and sorts containers by name :param containers: List of the container definitions :type containers: list of dict :param verbose: Print out newlines and indented JSON :type verbose: bool ...
python
{ "resource": "" }
q32239
ECSTransformer.ingest_volumes_param
train
def ingest_volumes_param(self, volumes): """ This is for ingesting the "volumes" of a task description """ data = {} for volume in volumes: if volume.get('host', {}).get('sourcePath'): data[volume.get('name')] = { 'path': volume.ge...
python
{ "resource": "" }
q32240
ECSTransformer._build_mountpoint
train
def _build_mountpoint(self, volume): """ Given a generic volume definition, create the mountPoints element """
python
{ "resource": "" }
q32241
MarathonTransformer.flatten_container
train
def flatten_container(self, container): """ Accepts a marathon container and pulls out the nested values into the top level """ for names in ARG_MAP.values(): if names[TransformationTypes.MARATHON.value]['name'] and \ '.' in names[TransformationTy...
python
{ "resource": "" }
q32242
MarathonTransformer._convert_volume
train
def _convert_volume(self, volume): """ This is for ingesting the "volumes" of a app description """
python
{ "resource": "" }
q32243
KubernetesTransformer._find_convertable_object
train
def _find_convertable_object(self, data): """ Get the first instance of a `self.pod_types` """ data = list(data) convertable_object_idxs = [ idx for idx, obj in enumerate(data) if obj.get('kind') in self.pod_types.keys() ]
python
{ "resource": "" }
q32244
KubernetesTransformer._read_stream
train
def _read_stream(self, stream): """ Read in the pod stream """ data = yaml.safe_load_all(stream=stream) obj = self._find_convertable_object(data)
python
{ "resource": "" }
q32245
KubernetesTransformer.ingest_volumes_param
train
def ingest_volumes_param(self, volumes): """ This is for ingesting the "volumes" of a pod spec """ data = {} for volume in volumes: if volume.get('hostPath', {}).get('path'): data[volume.get('name')] = { 'path': volume.get('hostPath...
python
{ "resource": "" }
q32246
KubernetesTransformer.flatten_container
train
def flatten_container(self, container): """ Accepts a kubernetes container and pulls out the nested values into the top level """ for names in ARG_MAP.values(): if names[TransformationTypes.KUBERNETES.value]['name'] and \ '.' in names[Transformatio...
python
{ "resource": "" }
q32247
KubernetesTransformer._build_volume
train
def _build_volume(self, volume): """ Given a generic volume definition, create the volumes element """ self.volumes[self._build_volume_name(volume.get('host'))] = { 'name': self._build_volume_name(volume.get('host')), 'hostPath': { 'path': volume.g...
python
{ "resource": "" }
q32248
Converter._convert_container
train
def _convert_container(self, container, input_transformer, output_transformer): """ Converts a given dictionary to an output container definition :type container: dict :param container: The container definitions as a dictionary :rtype: dict :return: A output_type contai...
python
{ "resource": "" }
q32249
transform
train
def transform(input_file, input_type, output_type, verbose, quiet): """ container-transform is a small utility to transform various docker container formats to one another. Default input type is compose, default output type is ECS Default is to read from STDIN if no INPUT_FILE is provided All...
python
{ "resource": "" }
q32250
ChronosTransformer.flatten_container
train
def flatten_container(self, container): """ Accepts a chronos container and pulls out the nested values into the top level """ for names in ARG_MAP.values(): if names[TransformationTypes.CHRONOS.value]['name'] and \ '.' in names[TransformationTypes...
python
{ "resource": "" }
q32251
ComposeTransformer.ingest_containers
train
def ingest_containers(self, containers=None): """ Transform the YAML into a dict with normalized keys """ containers = containers or self.stream or {} output_containers = [] for container_name, definition in containers.items():
python
{ "resource": "" }
q32252
sha256
train
def sha256(message, encoder=nacl.encoding.HexEncoder): """ Hashes ``message`` with SHA256. :param message: The message to hash. :type message: bytes :param encoder: A class that is able to encode the hashed message.
python
{ "resource": "" }
q32253
sha512
train
def sha512(message, encoder=nacl.encoding.HexEncoder): """ Hashes ``message`` with SHA512. :param message: The message to hash. :type message: bytes :param encoder: A class that is able to encode the hashed message.
python
{ "resource": "" }
q32254
blake2b
train
def blake2b(data, digest_size=BLAKE2B_BYTES, key=b'', salt=b'', person=b'', encoder=nacl.encoding.HexEncoder): """ Hashes ``data`` with blake2b. :param data: the digest input byte sequence :type data: bytes :param digest_size: the requested digest size; must be at most ...
python
{ "resource": "" }
q32255
siphash24
train
def siphash24(message, key=b'', encoder=nacl.encoding.HexEncoder): """ Computes a keyed MAC of ``message`` using the short-input-optimized siphash-2-4 construction. :param message: The message to hash. :type message: bytes
python
{ "resource": "" }
q32256
siphashx24
train
def siphashx24(message, key=b'', encoder=nacl.encoding.HexEncoder): """ Computes a keyed MAC of ``message`` using the 128 bit variant of the siphash-2-4 construction. :param message: The message to hash. :type message: bytes :param key: the
python
{ "resource": "" }
q32257
crypto_sign_keypair
train
def crypto_sign_keypair(): """ Returns a randomly generated public key and secret key. :rtype: (bytes(public_key), bytes(secret_key)) """ pk = ffi.new("unsigned char[]", crypto_sign_PUBLICKEYBYTES) sk = ffi.new("unsigned char[]", crypto_sign_SECRETKEYBYTES) rc = lib.crypto_sign_keypair(pk,...
python
{ "resource": "" }
q32258
crypto_sign_seed_keypair
train
def crypto_sign_seed_keypair(seed): """ Computes and returns the public key and secret key using the seed ``seed``. :param seed: bytes :rtype: (bytes(public_key), bytes(secret_key)) """ if len(seed) != crypto_sign_SEEDBYTES: raise exc.ValueError("Invalid seed")
python
{ "resource": "" }
q32259
crypto_sign
train
def crypto_sign(message, sk): """ Signs the message ``message`` using the secret key ``sk`` and returns the signed message. :param message: bytes :param sk: bytes :rtype: bytes """ signed = ffi.new("unsigned char[]", len(message) + crypto_sign_BYTES) signed_len = ffi.new("unsigned l...
python
{ "resource": "" }
q32260
crypto_sign_open
train
def crypto_sign_open(signed, pk): """ Verifies the signature of the signed message ``signed`` using the public key ``pk`` and returns the unsigned message. :param signed: bytes :param pk: bytes :rtype: bytes """ message = ffi.new("unsigned char[]", len(signed)) message_len = ffi.new...
python
{ "resource": "" }
q32261
crypto_sign_ed25519ph_update
train
def crypto_sign_ed25519ph_update(edph, pmsg): """ Update the hash state wrapped in edph :param edph: the ed25519ph state being updated :type edph: crypto_sign_ed25519ph_state :param pmsg: the partial message :type pmsg: bytes :rtype: None """ ensure(isinstance(edph, crypto_sign_ed25...
python
{ "resource": "" }
q32262
crypto_sign_ed25519ph_final_create
train
def crypto_sign_ed25519ph_final_create(edph, sk): """ Create a signature for the data hashed in edph using the secret key sk :param edph: the ed25519ph state for the data being signed :type edph: crypto_sign_ed25519ph_state :param sk: the ...
python
{ "resource": "" }
q32263
crypto_sign_ed25519ph_final_verify
train
def crypto_sign_ed25519ph_final_verify(edph, signature, pk): """ Verify a prehashed signature using the public key pk :param edph: the ed25519ph state for the data being verified :type edph: crypto_sign_ed255...
python
{ "resource": "" }
q32264
kdf
train
def kdf(size, password, salt, opslimit=OPSLIMIT_SENSITIVE, memlimit=MEMLIMIT_SENSITIVE, encoder=nacl.encoding.RawEncoder): """ Derive a ``size`` bytes long key from a caller-supplied ``password`` and ``salt`` pair using the argon2i memory-hard construct. the enclosing module...
python
{ "resource": "" }
q32265
str
train
def str(password, opslimit=OPSLIMIT_INTERACTIVE, memlimit=MEMLIMIT_INTERACTIVE): """ Hashes a password with a random salt, using the memory-hard argon2i construct and returning an ascii string that has all the needed info to check against a future password The default settings for ...
python
{ "resource": "" }
q32266
scrypt
train
def scrypt(password, salt='', n=2**20, r=8, p=1, maxmem=2**25, dklen=64): """ Derive a cryptographic key using the scrypt KDF. Implements the same signature as the ``hashlib.scrypt`` implemented in cpython version 3.6
python
{ "resource": "" }
q32267
crypto_secretbox
train
def crypto_secretbox(message, nonce, key): """ Encrypts and returns the message ``message`` with the secret ``key`` and the nonce ``nonce``. :param message: bytes :param nonce: bytes :param key: bytes :rtype: bytes """ if len(key) != crypto_secretbox_KEYBYTES: raise exc.Valu...
python
{ "resource": "" }
q32268
_checkparams
train
def _checkparams(digest_size, key, salt, person): """Check hash paramters""" ensure(isinstance(key, bytes), 'Key must be a bytes sequence', raising=exc.TypeError) ensure(isinstance(salt, bytes), 'Salt must be a bytes sequence', raising=exc.TypeError) ensure(...
python
{ "resource": "" }
q32269
generichash_blake2b_salt_personal
train
def generichash_blake2b_salt_personal(data, digest_size=crypto_generichash_BYTES, key=b'', salt=b'', person=b''): """One shot hash interface :param data: the input data to the hash function :param digest_size: must be at most ...
python
{ "resource": "" }
q32270
generichash_blake2b_init
train
def generichash_blake2b_init(key=b'', salt=b'', person=b'', digest_size=crypto_generichash_BYTES): """ Create a new initialized blake2b hash state :param key: must be at most :py:data:`.crypto_generichash_KEYBYTES_MAX` long :type...
python
{ "resource": "" }
q32271
generichash_blake2b_update
train
def generichash_blake2b_update(state, data): """Update the blake2b hash state :param state: a initialized Blake2bState object as returned from :py:func:`.crypto_generichash_blake2b_init` :type state: :py:class:`.Blake2State` :param data: :type data: bytes """
python
{ "resource": "" }
q32272
generichash_blake2b_final
train
def generichash_blake2b_final(state): """Finalize the blake2b hash state and return the digest. :param state: a initialized Blake2bState object as returned from :py:func:`.crypto_generichash_blake2b_init` :type state: :py:class:`.Blake2State` :return: the blake2 digest of the passe...
python
{ "resource": "" }
q32273
crypto_secretstream_xchacha20poly1305_init_push
train
def crypto_secretstream_xchacha20poly1305_init_push(state, key): """ Initialize a crypto_secretstream_xchacha20poly1305 encryption buffer. :param state: a secretstream state object :type state: crypto_secretstream_xchacha20poly1305_state :param key: must be :data:`.crypto_secretstre...
python
{ "resource": "" }
q32274
crypto_secretstream_xchacha20poly1305_push
train
def crypto_secretstream_xchacha20poly1305_push( state, m, ad=None, tag=crypto_secretstream_xchacha20poly1305_TAG_MESSAGE, ): """ Add an encrypted message to the secret stream. :param state: a secretstream state object :type state: crypto_secretstream_xchacha20poly1305_state :param m...
python
{ "resource": "" }
q32275
crypto_secretstream_xchacha20poly1305_init_pull
train
def crypto_secretstream_xchacha20poly1305_init_pull(state, header, key): """ Initialize a crypto_secretstream_xchacha20poly1305 decryption buffer. :param state: a secretstream state object :type state: crypto_secretstream_xchacha20poly1305_state :param header: must be :data:`.crypto...
python
{ "resource": "" }
q32276
crypto_secretstream_xchacha20poly1305_pull
train
def crypto_secretstream_xchacha20poly1305_pull(state, c, ad=None): """ Read a decrypted message from the secret stream. :param state: a secretstream state object :type state: crypto_secretstream_xchacha20poly1305_state :param c: the ciphertext to decrypt, the maximum length of an individual ...
python
{ "resource": "" }
q32277
crypto_secretstream_xchacha20poly1305_rekey
train
def crypto_secretstream_xchacha20poly1305_rekey(state): """ Explicitly change the encryption key in the stream. Normally the stream is re-keyed as needed or an explicit ``tag`` of :data:`.crypto_secretstream_xchacha20poly1305_TAG_REKEY` is added to a message to ensure forward secrecy, but this meth...
python
{ "resource": "" }
q32278
verify
train
def verify(password_hash, password): """ Takes a modular crypt encoded stored password hash derived using one of the algorithms supported by `libsodium` and checks if the user provided password will hash to the same string when using the parameters saved in the stored hash """ if password_ha...
python
{ "resource": "" }
q32279
kdf
train
def kdf(size, password, salt, opslimit=OPSLIMIT_SENSITIVE, memlimit=MEMLIMIT_SENSITIVE, encoder=nacl.encoding.RawEncoder): """ Derive a ``size`` bytes long key from a caller-supplied ``password`` and ``salt`` pair using the scryptsalsa208sha256 memory-hard construct. the en...
python
{ "resource": "" }
q32280
str
train
def str(password, opslimit=OPSLIMIT_INTERACTIVE, memlimit=MEMLIMIT_INTERACTIVE): """ Hashes a password with a random salt, using the memory-hard scryptsalsa208sha256 construct and returning an ascii string that has all the needed info to check against a future password The default s...
python
{ "resource": "" }
q32281
verify
train
def verify(password_hash, password): """ Takes the output of scryptsalsa208sha256 and compares it against a user provided password to see if they are the same :param password_hash: bytes :param password: bytes :rtype: boolean .. versionadded:: 1.2 """ ensure(len(password_hash) == ...
python
{ "resource": "" }
q32282
PrivateKey.from_seed
train
def from_seed(cls, seed, encoder=encoding.RawEncoder): """ Generate a PrivateKey using a deterministic construction starting from a caller-provided seed .. warning:: The seed **must** be high-entropy; therefore, its generator **must** be a cryptographic quality r...
python
{ "resource": "" }
q32283
SealedBox.encrypt
train
def encrypt(self, plaintext, encoder=encoding.RawEncoder): """ Encrypts the plaintext message using a random-generated ephemeral keypair and returns a "composed ciphertext", containing both the public part of the keypair and the ciphertext proper, encoded with the encoder. ...
python
{ "resource": "" }
q32284
SealedBox.decrypt
train
def decrypt(self, ciphertext, encoder=encoding.RawEncoder): """ Decrypts the ciphertext using the ephemeral public key enclosed in the ciphertext and the SealedBox private key, returning the plaintext message. :param ciphertext: [:class:`bytes`] The encrypted message to
python
{ "resource": "" }
q32285
release
train
def release(ctx, version): """ ``version`` should be a string like '0.4' or '1.0'. """ invoke.run("git tag -s {0} -m '{0} release'".format(version)) invoke.run("git push --tags") invoke.run("python setup.py sdist") invoke.run("twine upload -s dist/PyNaCl-{0}* ".format(version)) sessio...
python
{ "resource": "" }
q32286
randombytes
train
def randombytes(size): """ Returns ``size`` number of random bytes from a cryptographically secure random source. :param size: int :rtype: bytes
python
{ "resource": "" }
q32287
crypto_scalarmult_base
train
def crypto_scalarmult_base(n): """ Computes and returns the scalar product of a standard group element and an integer ``n``. :param n: bytes :rtype: bytes
python
{ "resource": "" }
q32288
crypto_scalarmult_ed25519_base
train
def crypto_scalarmult_ed25519_base(n): """ Computes and returns the scalar product of a standard group element and an integer ``n`` on the edwards25519 curve. :param n: a :py:data:`.crypto_scalarmult_ed25519_SCALARBYTES` long bytes sequence representing a scalar :type n: bytes :re...
python
{ "resource": "" }
q32289
nacl_bindings_pick_scrypt_params
train
def nacl_bindings_pick_scrypt_params(opslimit, memlimit): """Python implementation of libsodium's pickparams""" if opslimit < 32768: opslimit = 32768 r = 8 if opslimit < (memlimit // 32): p = 1 maxn = opslimit // (4 * r) for n_log2 in range(1, 63): # pragma: no branch...
python
{ "resource": "" }
q32290
crypto_pwhash_scryptsalsa208sha256_ll
train
def crypto_pwhash_scryptsalsa208sha256_ll(passwd, salt, n, r, p, dklen=64, maxmem=SCRYPT_MAX_MEM): """ Derive a cryptographic key using the ``passwd`` and ``salt`` given as input. The work factor can be tuned by by picking different values for the parameter...
python
{ "resource": "" }
q32291
crypto_pwhash_scryptsalsa208sha256_str
train
def crypto_pwhash_scryptsalsa208sha256_str( passwd, opslimit=SCRYPT_OPSLIMIT_INTERACTIVE, memlimit=SCRYPT_MEMLIMIT_INTERACTIVE): """ Derive a cryptographic key using the ``passwd`` and ``salt`` given as input, returning a string representation which includes the salt and the tuning param...
python
{ "resource": "" }
q32292
crypto_pwhash_scryptsalsa208sha256_str_verify
train
def crypto_pwhash_scryptsalsa208sha256_str_verify(passwd_hash, passwd): """ Verifies the ``passwd`` against the ``passwd_hash`` that was generated. Returns True or False depending on the success :param passwd_hash: bytes :param passwd: bytes :rtype: boolean """ ensure(len(passwd_hash) ...
python
{ "resource": "" }
q32293
crypto_pwhash_alg
train
def crypto_pwhash_alg(outlen, passwd, salt, opslimit, memlimit, alg): """ Derive a raw cryptographic key using the ``passwd`` and the ``salt`` given as input to the ``alg`` algorithm. :param outlen: the length of the derived key :type outlen: int :param passwd: The input password :type pass...
python
{ "resource": "" }
q32294
crypto_pwhash_str_alg
train
def crypto_pwhash_str_alg(passwd, opslimit, memlimit, alg): """ Derive a cryptographic key using the ``passwd`` given as input and a random ``salt``, returning a string representation which includes the salt, the tuning parameters and the used algorithm. :param passwd: The input password :type ...
python
{ "resource": "" }
q32295
crypto_pwhash_str_verify
train
def crypto_pwhash_str_verify(passwd_hash, passwd): """ Verifies the ``passwd`` against a given password hash. Returns True on success, raises InvalidkeyError on failure :param passwd_hash: saved password hash :type passwd_hash: bytes :param passwd: password to be checked :type passwd: bytes...
python
{ "resource": "" }
q32296
crypto_aead_chacha20poly1305_ietf_encrypt
train
def crypto_aead_chacha20poly1305_ietf_encrypt(message, aad, nonce, key): """ Encrypt the given ``message`` using the IETF ratified chacha20poly1305 construction described in RFC7539. :param message: :type message: bytes :param aad: :type aad: bytes :param nonce: :type nonce: bytes ...
python
{ "resource": "" }
q32297
crypto_aead_chacha20poly1305_encrypt
train
def crypto_aead_chacha20poly1305_encrypt(message, aad, nonce, key): """ Encrypt the given ``message`` using the "legacy" construction described in draft-agl-tls-chacha20poly1305. :param message: :type message: bytes :param aad: :type aad: bytes :param nonce: :type nonce: bytes :...
python
{ "resource": "" }
q32298
crypto_aead_xchacha20poly1305_ietf_encrypt
train
def crypto_aead_xchacha20poly1305_ietf_encrypt(message, aad, nonce, key): """ Encrypt the given ``message`` using the long-nonces xchacha20poly1305 construction. :param message: :type message: bytes :param aad: :type aad: bytes :param nonce: :type nonce: bytes :param key: :t...
python
{ "resource": "" }
q32299
crypto_core_ed25519_is_valid_point
train
def crypto_core_ed25519_is_valid_point(p): """ Check if ``p`` represents a point on the edwards25519 curve, in canonical form, on the main subgroup, and that the point doesn't have a small order. :param p: a :py:data:`.crypto_core_ed25519_BYTES` long bytes sequence representing a point on...
python
{ "resource": "" }