{"version":3,"sources":["../src/services/crypt/index.ts"],"names":[],"mappings":";AAGA,gCAAwB,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ5C;AAED,gCAAwB,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ5C;AAED,sCAA8B,MAAM,EAAE,MAAM,UAM3C;AAED,sCAA8B,MAAM,EAAE,MAAM,UAM3C;AAED,+BAAuB,IAAI,EAAE,MAAM,GAAG,MAAM,CAE3C","file":"index.d.ts","sourcesContent":["import { get as getConfig } from 'config';\nimport { createCipher, createDecipher, createHash } from 'crypto';\n\nexport function encrypt(text: string): string {\n    const cipher = createCipher(getConfig('crypt.algo'), getConfig('crypt.secret'));\n\n    let crypted = cipher.update(text, 'utf8', 'hex');\n\n    crypted += cipher.final('hex');\n\n    return crypted;\n}\n\nexport function decrypt(text: string): string {\n    const decipher = createDecipher(getConfig('crypt.algo'), getConfig('crypt.secret'));\n\n    let dec = decipher.update(text, 'hex', 'utf8');\n\n    dec += decipher.final('utf8');\n\n    return dec;\n}\n\nexport function encryptBuffer(buffer: Buffer) {\n    const cipher = createCipher(getConfig('crypt.algo'), getConfig('crypt.secret'));\n\n    const crypted = Buffer.concat([cipher.update(buffer), cipher.final()]);\n\n    return crypted;\n}\n\nexport function decryptBuffer(buffer: Buffer) {\n    const decipher = createDecipher(getConfig('crypt.algo'), getConfig('crypt.secret'));\n\n    const dec = Buffer.concat([decipher.update(buffer), decipher.final()]);\n\n    return dec;\n}\n\nexport function sha256(data: string): string {\n    return createHash('sha256').update(data).digest('base64');\n}\n"]}