<commit_before>var crypto = require('crypto');

var TheCityPlugin = function(city_app_secret) {
  if (city_app_secret == undefined) throw new Error('city_app_secret required');
  this.key = new Buffer(city_app_secret.substring(0,32));
}

TheCityPlugin.prototype.decrypt_city_data = function(encrypted_city_data, city_data_iv) {
    var data = new Buffer(encrypted_city_data, 'base64');
    var iv = new Buffer(city_data_iv, 'base64');
    var decipher = crypto.createDecipheriv('aes-256-cbc', this.key, iv);
    var decoded_data = decipher.update(data);
    return JSON.parse(decoded_data.toString('utf8'))
}

module.exports = TheCityPlugin;<commit_msg>asyc callbacks<commit_after>var crypto = require('crypto');

var TheCityPlugin = function(city_app_secret) {
  if (city_app_secret == undefined) throw new Error('city_app_secret required');
  this.key = new Buffer(city_app_secret.substring(0,32));
}

TheCityPlugin.prototype.decrypt_city_data = function(encrypted_city_data, city_data_iv, cb) {
    var data
      , iv
      , decipher
      , decoded_data
      , parsed_data
      , err

    data = new Buffer(encrypted_city_data, 'base64');
    iv = new Buffer(city_data_iv, 'base64');
    decipher = crypto.createDecipheriv('aes-256-cbc', this.key, iv);
    decoded_data = decipher.update(data, 'binary', 'utf8');
    decoded_data += decipher.final('utf8');
  
    try{
      parsed_data = JSON.parse(decoded_data);
    }
    catch(e) {
      err = e;
    }

    if (cb) {
      cb(err, parsed_data);
    } else {
      if (!err) {
        return parsed_data
      } else {
        return err
      }
    }

}

module.exports = TheCityPlugin;
{'fraction_non_alphanumeric': 0.1249241964827168, 'fraction_numerical': 0.013947847180109158, 'mean_word_length': 3.700854700854701, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5659947', 'n_tokens_mistral': 572, 'n_tokens_neox': 557, 'n_words': 106}