<commit_before>// Copyright 2014, Renasar Technologies Inc.
/* jshint node: true */

'use strict';

var di = require('di');

module.exports = encryptionServiceFactory;

di.annotate(encryptionServiceFactory, new di.Provide('Services.Encryption'));
di.annotate(encryptionServiceFactory,
    new di.Inject(
        'Promise',
        'Services.Configuration',
        'Encryption'
    )
);

function encryptionServiceFactory(Promise, configuration, Encryption) {
    var shared = '<KEY>';

    function EncryptionService () {
        this.encryption = new Encryption ();
    }

    EncryptionService.prototype.encrypt = function (data, iv) {
        return this.encryption.encrypt(
            data,
            configuration.get(
                'sharedKey',
                shared
            ),
            iv
        );
    };

    EncryptionService.prototype.decrypt = function (data) {
        return this.encryption.decrypt(
            data,
            configuration.get(
                'sharedKey',
                shared
            )
        );
    };

    EncryptionService.prototype.start = function start() {
        return Promise.resolve();
    };

    EncryptionService.prototype.stop = function stop() {
        return Promise.resolve();
    };

    return new EncryptionService();
}<commit_msg>move configuration check to start<commit_after>// Copyright 2014, Renasar Technologies Inc.
/* jshint node: true */

'use strict';

var di = require('di');

module.exports = encryptionServiceFactory;

di.annotate(encryptionServiceFactory, new di.Provide('Services.Encryption'));
di.annotate(encryptionServiceFactory,
    new di.Inject(
        'Promise',
        'Services.Configuration',
        'Encryption'
    )
);

function encryptionServiceFactory(Promise, configuration, Encryption) {
    var shared = '<KEY>';

    function EncryptionService () {
        this.encryption = new Encryption ();
    }

    EncryptionService.prototype.encrypt = function (data, iv) {
        return this.encryption.encrypt(
            data,
            this.key,
            iv
        );
    };

    EncryptionService.prototype.decrypt = function (data) {
        return this.encryption.decrypt(
            data,
            this.key
        );
    };

    EncryptionService.prototype.start = function start() {
        this.key = configuration.get('sharedKey', shared);

        return Promise.resolve();
    };

    EncryptionService.prototype.stop = function stop() {
        return Promise.resolve();
    };

    return new EncryptionService();
}
{'fraction_non_alphanumeric': 0.11089341692789968, 'fraction_numerical': 0.003134796238244514, 'mean_word_length': 2.30699481865285, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '743276', 'n_tokens_mistral': 690, 'n_tokens_neox': 665, 'n_words': 143}