import { getSharedAppEnv } from "../env/appEnv" ; import { getCredentials } from "../credentials/channel" ; import Credentials from "../credentials/Credentials" ; import { BufferLike } from "../types" ; export const ATTACHMENT_EXT = "bcatt" ; export function decryptAttachment ( buff , credentials ) { const { masterPassword } = getCredentials ( credentials . id ) ; const decrypt = getSharedAppEnv ( ) . getProperty ( "crypto/v2/decryptBuffer" ) ; return decrypt ( buff , masterPassword ) ; } export function encryptAttachment ( buff , credentials ) { const { masterPassword } = getCredentials ( credentials . id ) ; const encrypt = getSharedAppEnv ( ) . getProperty ( "crypto/v2/encryptBuffer" ) ; return encrypt ( buff , masterPassword ) ; } export function getBufferSize ( buff ) { if ( typeof buff . byteLength !== "undefined" ) { return buff . byteLength ; } return ( < Buffer > buff ) . length ; }