Skip to content

Instantly share code, notes, and snippets.

@AvocadoVenom
Created February 9, 2023 09:53
Show Gist options
  • Save AvocadoVenom/b9b9140a3fb9544c37d0177a11b83fbe to your computer and use it in GitHub Desktop.
Save AvocadoVenom/b9b9140a3fb9544c37d0177a11b83fbe to your computer and use it in GitHub Desktop.
Data models for Cryptography operations
export interface EncryptionKeyManager {
parseKey: (key: ArrayBuffer) => Promise<CryptoKey>
readKey: (key: CryptoKey) => Promise<ArrayBuffer>
}
export interface CryptographyManager {
generateIv: () => Uint8Array
encrypt: (data: string, key: CryptoKey) => Promise<EncryptionPayload>
decrypt: (cipher: ArrayBuffer, key: CryptoKey, iv: Uint8Array) => Promise<string>
}
export type EncryptionPayload = {
/**
* Initial Vector
*/
iv: Uint8Array
/**
* Encryption key
*/
key: ArrayBuffer
/**
* Encryption output
*/
cipher: ArrayBuffer
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment