Skip to main content

Clears the contents of bytes or integers containing cryptographic material

Project description

[![Build Status](](

## Install:

pip install SecureBytes

## Use:

Currently supports clearing integers, strings and bytes

from SecureBytes import clearmem, safemem

x = b’data that must be removed’

copy_of_x = x


assert(b’data’ not in copy_of_x)

In python3 only, temporarily overriding mem allocator to zero ram and prevent paging:

with safemem():
x = b’data that must be removed’ del x

# x is not in ram

Currently, safemem and scanmem aren’t supported on all pythons and platforms, use import safemem_supported, scanmem_supported to check.

## Warnings:

  • Do not try to derive from str or bytes… extra copies of your data will be made
  • Clearing strings and bytes also clears all references to them
  • If you choose store sensitive material in a class, and put clearmem in __del__, it will only be cleared when the last reference is freed
  • “safemem” is not yet efficient (TODO), and it only prevents swapping on Windows (TODO)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for SecureBytes, version 0.3.5
Filename, size File type Python version Upload date Hashes
Filename, size SecureBytes-0.3.5.tar.gz (6.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page