Skip to content
uencoder
TASK

Securely wipe sensitive data from memory

Cryptographic keys and plaintext must be zeroed from memory after use. Learn why memset is not enough and how to prevent compiler optimization.

  1. 1

    After using a cryptographic key or plaintext, it must be overwritten with zeros in memory. Simply letting the variable go out of scope is insufficient — the data remains in memory until the page is reused. The challenge: compilers optimize away memset(key, 0, len) if the key is never read again.

  2. 2
    Hash Calculator →

    Hash sensitive data before processing if you need to retain a non-reversible representation. The hash output replaces the plaintext in memory — the original is wiped after hashing.

  3. 3
    Base64 Encoder →

    Encode sensitive data for transmission, then wipe the original plaintext from memory. The encoded form is not the secret — it is the transport representation. Wipe both after use.

  4. 4

    In C/C++, use explicit_bzero() or a volatile pointer to prevent the compiler from optimizing away the zeroing. In JavaScript, the language does not guarantee memory zeroing — use Uint8Array and overwrite all bytes, but be aware the GC may not immediately reclaim the memory. For truly sensitive operations, use a Web Worker and terminate it after use.

Frequently asked questions

Why does the compiler optimize away memset?
If the compiler sees that the buffer is never read after memset(buf, 0, len), it considers the zeroing a "dead store" and removes it for performance. Functions like explicit_bzero use volatile semantics to prevent this optimization.
Is this relevant in JavaScript?
JavaScript strings are immutable and cannot be zeroed — avoid storing secrets in strings. Use Uint8Array (mutable) and overwrite all bytes. However, the GC may copy data during compaction, leaving copies in memory. For maximum security, use a Worker and terminate it, or use WASM with manual memory management.

Workflows that solve this

Convert Ascii85 to Base64
Decode Ascii85 and re-encode as Base64 for wider compatibility.
PIPELINE
Convert Base2048 to Base64
Decode Base2048 (emoji) and re-encode as Base64 for standard transport.
PIPELINE
Convert Base32 to Base64
Decode a Base32-encoded string into raw bytes and re-encode as Base64 for more compact representation.
PIPELINE
Convert Base58 to Base64
Decode Base58 and re-encode as Base64 for standard compatibility.
PIPELINE
Base64 encode then decode round-trip
Encode text to Base64 and decode it back to verify the round-trip preserves the original data.
PIPELINE
Blowfish Encrypt then Base64
Blowfish encrypt then Base64-encode for text-safe transport.
PIPELINE
DES Encrypt then Base64
DES encrypt then Base64-encode for legacy compatibility.
PIPELINE
Encode a JSON payload for URL transport
Prepare a JSON document for a URL parameter: pretty-print, Base64-encode, then percent-encode — the exact inverse of the nested-parameter decode chain.
PIPELINE
AES encrypt then Base64 encode
Encrypt plaintext with AES and encode the ciphertext as Base64 for text-safe transport.
PIPELINE
Hash content and encode as Base64
Compute a hash of the input and encode the hash digest as Base64 for compact transport.
PIPELINE
Hash text and verify integrity
Compute a hash of the input text and compare it against an expected hash to verify integrity.
PIPELINE
Hash text and verify with CRC32 checksum
Compute both a cryptographic SHA-256 hash and a CRC32 checksum for data integrity verification.
PIPELINE
Convert Hex to Base64
Decode a hexadecimal string into raw bytes and re-encode it as Base64 for compact transport.
PIPELINE
HMAC Sign then Base64 Encode
Generate HMAC signature then Base64-encode for API auth headers.
PIPELINE
MD5 Hash then Base58 Encode
Compute MD5 hash then encode as Base58 for compact representation.
PIPELINE
Morse Encode and Base64 Transport
Encode text as Morse code then Base64-encode for digital transport.
PIPELINE
Multi-hash speed comparison
Hash the input and benchmark multiple hash algorithms to compare their speed and output.
PIPELINE
Generate Password and Hash
Generate a random password then hash it for secure storage.
PIPELINE
RC4 Encrypt then Base64
RC4 encrypt then Base64-encode for transport.
PIPELINE
RIPEMD-160 Hash then Base64
Compute RIPEMD-160 hash then Base64-encode for transport.
PIPELINE
SHA3-256 Hash with CRC32 Checksum
Compute SHA3-256 hash then CRC32 checksum for dual integrity verification.
PIPELINE
SHA-512 Hash then Hex Encode
Compute SHA-512 hash then encode as hex for readability.
PIPELINE
Reverse Text and Hash
Reverse text then compute SHA-256 hash of the reversed result.
PIPELINE
Scramble Text and Hash
Scramble text then hash the scrambled result.
PIPELINE
Shuffle Text and Base64 Encode
Shuffle text characters then Base64-encode the result.
PIPELINE
Unicode Escape and Base64 Encode
Unicode-escape text then Base64-encode for ASCII-safe transport.
PIPELINE
URL Encode then Base64 Double Encode
URL-encode then Base64-encode for double encoding in API payloads.
PIPELINE
UUencode then Base64
UUencode text then Base64-encode the result for double encoding.
PIPELINE
Generate UUID and Base64 Encode
Generate a UUID then Base64-encode it for compact storage.
PIPELINE

Learn more

Want to understand why?

Related tools