UNPKG

@meeco/cryppo

Version:

In-browser encryption and decryption. Clone of Ruby Cryppo

52 lines (51 loc) 1.83 kB
import { EncryptionKey } from '../encryption-key'; import { IRandomKeyOptions } from '../key-derivation/derived-key'; import { SerializationFormat } from '../serialization-versions'; import { CipherStrategy } from '../strategies'; export interface IEncryptionOptionsWithoutKey { /*** * Data to encrypt */ data: Uint8Array; /** * Encryption/Cipher strategy to use */ strategy: CipherStrategy; /** * Defaults to 32 - length to use for generated key */ keyLength?: number; /** * @deprecated Primarily for testing purposes. */ iv?: string; } export interface IEncryptionArtifacts { iv: any; at: any; ad: any; } export declare type IEncryptionOptions = IEncryptionOptionsWithoutKey & { key: EncryptionKey; }; export interface IEncryptionResult { serialized: string | null; encrypted: string | null; } export declare function encryptWithGeneratedKey({ data, strategy, keyLength, iv }: IEncryptionOptionsWithoutKey, serializationVersion?: SerializationFormat): Promise<IEncryptionResult & { generatedKey: EncryptionKey; }>; export declare function encryptWithKeyDerivedFromString({ passphrase, data, strategy, iv, serializationVersion, }: { passphrase: string; data: Uint8Array; strategy: CipherStrategy; iv?: string; serializationVersion?: SerializationFormat; }): Promise<IEncryptionResult & IRandomKeyOptions & { key: EncryptionKey; }>; export declare function encryptWithKey({ key, data, strategy, iv }: IEncryptionOptions, serializationVersion?: SerializationFormat): Promise<IEncryptionResult>; export declare function encryptWithKeyUsingArtefacts({ key, data, strategy, iv, }: IEncryptionOptions): { encrypted: string | null; artifacts?: any; };