import { Ciphers, CipherTagLengths } from './ciphers.js';
/**
 * Encrypt plaintext buffer to ciphertext buffer
 *
 * Only supports AES-GCM
 * @see https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/decrypt
 *
 * @param key Encryption key
 * @param plaintext Buffer to encrypt
 * @param iv Initialization vector
 * @param tagLength Size (bits) of authentication tag
 * @returns Resolves ciphertext buffer
 */
export default async function encrypt(key, plaintext, iv, tagLength) {
    return crypto.subtle.encrypt({
        name: Ciphers.AesGcm,
        iv,
        tagLength: tagLength || CipherTagLengths.AesGcm,
    }, key, plaintext);
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW5jcnlwdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9uYW5vdGRmLWNyeXB0by9lbmNyeXB0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxPQUFPLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxXQUFXLENBQUM7QUFFdEQ7Ozs7Ozs7Ozs7O0dBV0c7QUFDSCxNQUFNLENBQUMsT0FBTyxDQUFDLEtBQUssVUFBVSxPQUFPLENBQ25DLEdBQWMsRUFDZCxTQUFxQixFQUNyQixFQUFjLEVBQ2QsU0FBa0I7SUFFbEIsT0FBTyxNQUFNLENBQUMsTUFBTSxDQUFDLE9BQU8sQ0FDMUI7UUFDRSxJQUFJLEVBQUUsT0FBTyxDQUFDLE1BQU07UUFDcEIsRUFBRTtRQUNGLFNBQVMsRUFBRSxTQUFTLElBQUksZ0JBQWdCLENBQUMsTUFBTTtLQUNoRCxFQUNELEdBQUcsRUFDSCxTQUFTLENBQ1YsQ0FBQztBQUNKLENBQUMifQ==