WebRTC DTLS/SRTP encryption
WebRTC mandates two complementary protocols for encrypted communication:- DTLS (Datagram Transport Layer Security) — negotiates session keys and authenticates both peers during the WebRTC handshake. It is the UDP equivalent of TLS and provides the same certificate-based security model.
- SRTP (Secure Real-time Transport Protocol) — encrypts the actual media and data payloads in flight using the keys established by DTLS.
| Transfer type | Protected by |
|---|---|
| File transfer (data channel) | DTLS + SRTP |
| Video conferencing (audio/video tracks) | DTLS + SRTP via LiveKit |
| Text / chat messages (data channel) | DTLS + SRTP |
DTLS/SRTP is the same encryption stack used by Zoom and Google Meet. It is a mandatory part of the WebRTC specification; no WebRTC-compliant browser can skip it.
SHA-256 file integrity verification
Transport encryption prevents eavesdropping, but it does not by itself guarantee the file was not corrupted during chunked reassembly. HashDrop adds an explicit integrity check using SHA-256.How the hash is computed
The sender callscalculateFileHash before the transfer begins. The function reads the entire file into an ArrayBuffer and passes it to the browser’s native crypto.subtle.digest implementation:
How the hash is verified
After the receiver reassembles all chunks into a completeFile object, calculateFileHash is called again on the reconstructed file. The result is compared against the sender’s hash using verifyFileHash:
Verification flow
Sender computes hash
Before any data is sent,
calculateFileHash produces a SHA-256 digest of the original file using crypto.subtle.digest.Metadata transmitted
The hash, filename, MIME type, and total size are sent to the receiver over the encrypted WebRTC data channel.
File streams as chunks
The file is split into 16 KB binary chunks, sequenced, and streamed across the peer connection.
Receiver reassembles
The receiver collects all chunks and reassembles them into a single
Blob in the correct order.Web Crypto API usage
HashDrop relies exclusively on the browser’s built-inwindow.crypto object and never ships a third-party cryptography library for core security operations:
| Operation | API used |
|---|---|
| SHA-256 file hashing | crypto.subtle.digest('SHA-256', buffer) |
| Warp Code generation | crypto.getRandomValues(new Uint32Array(1)) |