How to use the rfc4648.base64url.stringify function in rfc4648

To help you get started, we’ve selected a few rfc4648 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github paragonie / ciphersweet-js / lib / backend / moderncrypto.js View on Github external
if (!Buffer.isBuffer(aad)) {
                aad = await Util.toBuffer(aad);
            }
            aad = Buffer.concat([nonce, aad]);
        } else {
            aad = nonce;
        }

        let ciphertext = await sodium.crypto_aead_xchacha20poly1305_ietf_encrypt(
            plaintext,
            nonce,
            new CryptographyKey(encKey),
            aad
        );
        await sodium.sodium_memzero(encKey);
        return MAGIC_HEADER + base64url.stringify(
            Buffer.concat([nonce, ciphertext])
        );
    }
github paragonie / ciphersweet-js / lib / backend / fipsrypto.js View on Github external
} else {
            mac = await Util.hmac(
                'sha384',
                Util.pack([
                    Buffer.from(MAGIC_HEADER, 'binary'),
                    hkdfSalt,
                    ctrNonce,
                    ciphertext
                ]),
                macKey,
                true
            );
        }
        await sodium.sodium_memzero(macKey);

        return MAGIC_HEADER + base64url.stringify(
            Buffer.concat([
                hkdfSalt,
                ctrNonce,
                mac,
                ciphertext
            ])
        );
    }
github paragonie / ciphersweet-js / lib / transformation / compound.js View on Github external
static packString(str)
    {
        return Util.store64_le(str.length).toString('hex') +
            base64url.stringify(Buffer.from(str));
    }
};