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

FileEncryptionAdapter   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 6
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 6
dl 0
loc 6
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A encrypt 0 4 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