Passed
Pull Request — master (#89)
by Mathieu
01:31
created

server/src/Infrastructure/Adapter/FileEncryptionAdapter.ts   A

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 13
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 10
mnd 0
bc 0
fnc 2
dl 0
loc 13
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A FileEncryptionAdapter.encrypt 0 4 1
A FileEncryptionAdapter.descrypt 0 2 1
1
import * as crypto from 'crypto';
2
import {IFileEncryption} from 'src/Application/IFileEncryption';
3
4
export class FileEncryptionAdapter implements IFileEncryption {
5
  public encrypt(buffer: Buffer, password: string): Buffer {
6
    const cipher = crypto.createCipher('aes-256-cbc', password);
7
8
    return Buffer.concat([cipher.update(buffer), cipher.final()]);
9
  }
10
11
  public descrypt(filePath: string, password: string) {}
12
}
13