IEncrypt constructor
@param options {Object}
551575
function IEncrypt(options){
	options = options || {};
	var key = options.key ? new Buffer(options.key) : crypto.randomBytes(32);
	var debug = options.debug || false;
	
	/**
	 * Encryption method.
	 * @param data - What to encrypt it can be an object, string or number.
	 * @return {String} the encrypted text or null on fail
	 */
	this.encrypt = function(data){
		try{
			//serialize
			var original = serialize(data);
			
			//if serialization failed throw an error
			if(!original) throw new Error('Invalid type of object given for encryption');
			
			//initialization vector
			var vector = new Buffer(crypto.randomBytes(16));
			
			//new cipher
			var cipher = crypto.createCipheriv('aes256', key, vector);
			
			//the encrypted text
			var encrypted = cipher.update(original,'utf8','base64') + cipher.final('base64');
			
			//the signature for the combination of encrypted text and initialization vector
			var hash = this.sign(encrypted+vector.toString('base64'));
			
			//return token ecrypted.vector.hash
			return encrypted + "." + vector.toString('base64') + "." + hash;
		}
		catch(e){
			if(debug) console.error('An error occured while encrypting : %s',e.stack);
			return null;
		}
	};
	
	/**
	 * Decryption method.
	 * @param text {String} to encrypt
	 * @returns {Object} || {String} || {Number} || null on fail
	 */
	this.decrypt = function(text){
		var decipher,
			original,
			t,
			encrypted,
			vector,
			hash,
			new_hash;
		try{
			// split text and save each value (encrypted text,vector,hash)
			t=text.split(".");
			encrypted = t[0];
			vector = new Buffer(t[1], 'base64');
			hash = t[2];
			
			//check data integrity by validating signature 
			if(!this.validate(encrypted+t[1], hash)){
				throw new Error('Could not verify signature');
			}
			
			//new decipher
			decipher = crypto.createDecipheriv('aes256', key, vector);
		    
			//return the resulted object
			original = decipher.update(encrypted, 'base64', 'utf8') + decipher.final('utf8');
			try{
				return JSON.parse(original);
			}
			catch(e){
				return (!isNaN(parseFloat(original)) && isFinite(original) ? parseFloat(original) : original);
			}
		}
		catch(e){
			if(debug) console.error('An error occured while decrypting : %s',e.stack);
			return null;
		}
	};
	
	/**
	 * Produce a signature for the given object
	 * @param data {Object} || {String} || {Number}
	 * @param format {string} The format of the signature - Default is 'base64'
	 * @returns {String} the signature or null on fail
	 */
	this.sign = function(data, format){
		try{
			// Serialize data
			var serialized = serialize(data);
			
			// If not serialized properly throw an Error
			if(!serialized) throw new Error('Cannot serialize given type of object');
			
			// Set formating
			format = format || 'base64';
			
			// Generate and return HMAC
			return crypto.createHmac('sha256', key).update(serialized).digest(format);
		}
		catch(e){
			if(debug) console.error('An error occured while signing : %s',e.stack);
			return null;
		}
	}
	
	/**
	 * Validate data signature
	 * @param data  {Object} || {String} || {Number}
	 * @param signature {String} the produced signature for the data
	 * @param format {String} format of the signature. Default is 'base64'
	 * @return {Boolean}
	 */
	this.validate = function(data, signature, format){
		var new_sign = this.sign(data,format);
		return new_sign?compare(signature,new_sign):false;
	}
	
	/**
	 * Private serialization method
	 * @private
	 * @param data {Object} || {String} || {Number}
	 * @returns {String} or null on fail
	 */
	var serialize = function(data){
		return typeof data === 'object' 
			? JSON.stringify(data) 
			: (typeof data === 'string' || typeof data === 'number' ? String(data) : null);
	}
}
825803
def _initialize_integrity_checkers(self, options):
        # type: (Descriptor, blobxfer.models.options.Upload) -> None
        
        if self._ase.is_encrypted:
            # ensure symmetric key exists
            if blobxfer.util.is_none_or_empty(
                    self._ase.encryption_metadata.symmetric_key):
                raise RuntimeError(
                    ('symmetric key is invalid: provide RSA private key '
                     'or metadata corrupt for {}').format(
                         self.local_path.absolute_path))
            self.hmac = self._ase.encryption_metadata.initialize_hmac()
        # both hmac and md5 can be enabled
        if (options.store_file_properties.md5 and
                not self.remote_is_append_blob):
            self.md5 = blobxfer.util.new_md5_hasher()
1164396
function setting(options) {
  var conf = {};

  if (options === null || typeof options !== 'object') {
    options = {};
  }

  for (var key in defaultSetting) {
    conf[key] = options[key] === undefined ? defaultSetting[key] : options[key];
  }

  conf.format = defaultFormat(['json', 'xml'].indexOf(conf.format.toLowerCase()));

  var prefix = conf.prefix;
  if ((typeof prefix === 'string' || util.isRegExp(prefix)) && !options.prefixPattern) {
    conf.prefixPattern = util.isRegExp(prefix) ? prefix : new RegExp(prefix);
  }

  if (conf.authenticate) {
    conf.deny = options.deny;
    conf.authenticatePattern = options.authenticatePattern || conf.prefixPattern;

    if (conf.authenticate.constructor.name !== 'GeneratorFunction') {
      console.error('authenticate should be a GeneratorFunction');
      conf.authenticate = false;
    }
    if (conf.deny.constructor.name !== 'GeneratorFunction') {
      console.error('deny should be a GeneratorFunction');
    }
  }

  return conf;
}
673653
function(options) {
  this.name = options.name;
  this.isInternal = options.isInternal;
  this.pluginModule = options.pluginModule;
  this.pluginPath = options.pluginPath;
  this.pluginConfig = options.pluginConfig;
  this.shouldInterceptLogs = options.interceptLogs;
  this.clientWeb3Providers = [];
  this.beforeDeploy = [];
  this.contractsGenerators = [];
  this.generateCustomContractCode = null;
  this.testContractFactory = null;
  this.pipeline = [];
  this.pipelineFiles = [];
  this.console = [];
  this.contractsConfigs = [];
  this.contractsFiles = [];
  this.compilers = [];
  this.serviceChecks = [];
  this.dappGenerators = [];
  this.pluginTypes = [];
  this.uploadCmds = [];
  this.apiCalls = [];
  this.imports = [];
  this.embarkjs_code = [];
  this.embarkjs_init_code = {};
  this.embarkjs_init_console_code = {};
  this.afterContractsDeployActions = [];
  this.onDeployActions = [];
  this.eventActions = {};
  this._loggerObject = options.logger;
  this.logger = this._loggerObject; // Might get changed if we do intercept
  this.events = options.events;
  this.config = options.config;
  this.plugins = options.plugins;
  this.fs = options.fs;
  this.env = options.env;
  this.loaded = false;
  this.currentContext = options.context;
  this.acceptedContext = options.pluginConfig.context || [constants.contexts.any];
  this.version = options.version;
  this.constants = constants;

  if (!Array.isArray(this.currentContext)) {
    this.currentContext = [this.currentContext];
  }
  if (!Array.isArray(this.acceptedContext)) {
    this.acceptedContext = [this.acceptedContext];
  }
}
1101230
def evaluate_attr_encrypted_option(option)
        if option.is_a?(Symbol) && respond_to?(option)
          send(option)
        elsif option.respond_to?(:call)
          option.call(self)
        else
          option
        end
      end
1140231
function encrypt(userKey, plainText) {
        var i
          , offset
          , ct = []
          , tmpBlockEncrypt;

        if (utils.isAnArray(userKey) &&
          utils.isAnArray(plainText)) {

          userKey = new Uint8Array(userKey);
          plainText = new Uint8Array(plainText);
        } else {

          throw 'Inputs must be an array';
        }

        userKey = makeKey(userKey);

        for (offset = 0; offset < plainText.length; offset += 16) {

          tmpBlockEncrypt = blockEncrypt(plainText, offset, userKey);
          for (i = 0; i < tmpBlockEncrypt.length; i += 1) {

            ct.push(tmpBlockEncrypt[i]);
          }
        }

        return ct;
      }
570031
function encryptPassword(password, callback) {
        bcrypt.gen_salt(workFactor, function(err, salt) {
            if (err) callback(err);
            
            bcrypt.encrypt(password, salt, function(err, hashedPassword) {
                if (err) callback(err);
                
                callback(null, hashedPassword);
            });
        });
    }
733601
function secretKey(length, options = {}) {
  if (!length || length < 1) {
    return '';
  }

  if (!options.crypto || typeof options.crypto.randomBytes !== 'function') {
    throw new Error('Expecting options.crypto to have a randomBytes function');
  }

  return options.crypto
    .randomBytes(length)
    .toString('base64') // convert format
    .slice(0, length); // return required number of characters
}
154878
function INI(options){
  if(typeof options === 'string'){
    var obj = INI.parse(fs.readFileSync(options, 'utf8'));
    for(var k in obj) this[ k ] = obj[ k ];
  }
  if(typeof options === 'object'){
    this.obj = options;
  }
  return this;
}
839485
function encrypt(key, iv, data) {
    if(!Buffer.isBuffer(key)) {
        assert(typeof key === 'string');
        key = Buffer.from(key, 'binary')
    }

    if(!Buffer.isBuffer(iv)) {
        assert(typeof iv === 'string');
        iv = Buffer.from(iv, 'binary')
    }

    if(!Buffer.isBuffer(data)) {
        assert(typeof data === 'string');
        data = Buffer.from(data, 'binary')
    }

    var crypted = aes.encipher(data, key, iv);

    crypted = Buffer.from(crypted, 'binary');
    
    let ret = Buffer.alloc(crypted.length*2);
    for(let i = 0; i < crypted.length; i++){
        ret[2*i] = (crypted[i] >> 4) + 97;
        ret[2*i+1] = (crypted[i] & 0x0F) + 97;
    }
    return ret.toString('binary');
}
1094293
function init(options) {
    if (options === void 0) { options = {}; }
    if ('debug' in options) {
        diag.debug.enabled = options.debug;
        Q.longStackSupport = options.debug;
    }
    if ('serverUrl' in options) {
        var myURL = url.parse(options.serverUrl);
        if (!myURL.protocol && !myURL.host) {
            return Q.reject(new Error(options.serverUrl + " is not an accepted Url, please add a Host and a Protocol."));
        }
    }
    _.assignWith(exports.initOptions, cloneServerInitOptions(options), function (left, right) { return _.isUndefined(right) ? left : right; });
    if ('push' in options) {
        exports.initOptions.push = _.cloneDeep(options.push);
    }
    return device.ready;
}
794707
function _initStorage(options) {
        var self = this;
        var dbInfo = {};
        if (options) {
            for (var i in options) {
                dbInfo[i] = options[i];
            }
        }

        dbInfo.keyPrefix = dbInfo.name + '/';

        self._dbInfo = dbInfo;
        return Promise.resolve();
    }
242382
def create_cipher(klass, options, value)
        options = options.is_a?(Proc) ? options.call(self) : options.dup
        
        # Only use the contextual information for this plugin's ciphers
        klass.parent == EncryptedAttributes ? klass.new(value, options) : klass.new(options)
      end
248991
function readSecure(user, options) {
    // jscs:disable
    // jshint -W040
    const self = this;
    // jshint +W040
    // jscs:enable
    const shield = self.constructor.shield;
    const action = 'read';
    const rules = shield.getApplicableRules(action);
    return shield._fetch.call(self, options)
        .then(function runShieldRules(result) {
            // TODO: investigate what happens if fetch returns nothing (err?)
            return applyRules(rules, self, user)
                .then(function resolveResult() {
                    return result;
                });
        });
}
956665
function init(options) {

    var fs = require('fs');
    var path = require('path');
    var rootdir = path.dirname(require.main);
    var options = options || {
        config: require(path.join(rootdir, 'config.json')),
        root: rootdir,
        callback: function (noop) {}
    };
    var def = {};
    function ModulePaths (moduledir) {
        this.moduledir = moduledir;
    }

    ModulePaths.prototype.then = function (accept, reject) {
      var moduledir = this.moduledir;
      fs.readdir(moduledir, function (err, files) {
        if (err) reject(err);
        files.forEach(function (file) {
            var name = path.basename(file, '.js');
            def[name] = path.join(moduledir, name);
        });
        accept();
      });
    };
    var pubpath = new ModulePaths(path.join(path.dirname(module.filename), '..', 'public', 'js'));
    var prvpath = new ModulePaths(path.join(path.dirname(module.filename), '..', 'private', 'js'));

    Promise.all([pubpath, prvpath])
        .then(function () {
            var requirejs = require('requirejs');
            requirejs.config({
                baseUrl: path.join(rootdir),
                paths: def
            });

            requirejs(['loader_factory'], function (LoaderFactory) {
                var fs = require('fs');
                var config = options.config;
                config.paths.push(path.dirname(pubpath.moduledir));
                var loader = 'loader_express';
                var db = 'db_mongo';
                if (config.loader) loader = config.loader;
                if (config.db) db = config.db;

                new LoaderFactory().create(loader, db, function (loader) {
                    loader.init(config, options.callback);
                });
            });
        })
    .catch(function (err) {
        console.error('err:', err);
    });
}
649680
function Startline(options) {

  event.call(this);
  var self = this; // closure
  var temp = '';
  this.options = options;
  this.head = 0;
  this.tail = 0;
  this.line = 0;
  this._stream = null;

  if (options.rc4 || options.autokey) { // cipher
    var cipher;
    this._stream = interfac(this.options, options.start, options.end);
    if (options.rc4) {
      cipher = require('arc4')('arc4', String(options.rc4), options.lodash);
      this._stream.on('data', function(callbacks) {

        var callback = cipher.decodeBuffer(callbacks).toString();
        for (var i = 0, ii = callback.length; i < ii; ++i) {
          if (callback[i] === eol) {
            self.tail = self.head + self.line;
            self.head = self.tail + temp.length;
            self.emit('line', temp);
            self.line = 1;
            temp = '';
          } else {
            temp += callback[i];
          }
        }
        if (temp.length > 0) {
          self.tail = self.head + self.line;
          self.head = self.tail + temp.length;
          self.emit('line', temp);
          self.line = 1;
        }
        return;
      });

    } else {
      cipher = require('autokey')(String(options.autokey), options.lodash);
      this._stream.on('data', function(callbacks) {

        var callback = cipher.decodeBuffer(callbacks).toString();
        for (var i = 0, ii = callback.length; i < ii; ++i) {
          if (callback[i] === eol) {
            self.tail = self.head + self.line;
            self.head = self.tail + temp.length;
            self.emit('line', temp);
            self.line = 1;
            temp = '';
          } else {
            temp += callback[i];
          }
        }
        if (temp.length > 0) {
          self.tail = self.head + self.line;
          self.head = self.tail + temp.length;
          self.emit('line', temp);
          self.line = 1;
        }
        return;
      });
    }

  } else if (options.end >= 0) { // no cipher, EOF
    this._stream = interfac(this.options, options.start, options.end);
    this._stream.on('data', function(callbacks) {

      var callback = callbacks.toString();
      for (var i = 0, ii = callback.length; i < ii; ++i) {
        if (callback[i] === eol) {
          self.tail = self.head + self.line;
          self.head = self.tail + temp.length;
          self.emit('line', temp);
          self.line = 1;
          temp = '';
        } else {
          temp += callback[i];
        }
      }
      if (temp.length > 0) {
        self.tail = self.head + self.line;
        self.head = self.tail + temp.length;
        self.emit('line', temp);
        self.line = 1;
      }
      return;
    });

  } else { // file
    this._stream = readlin(this.options, options.start, options.end);
    this._stream.on('line', function(callback) {

      self.tail = self.head + self.line;
      self.head = self.tail + callback.length;
      self.emit('line', callback);
      self.line = 1;
      return;
    });
  }

  // standard events
  this._stream.on('pause', function() {

    return self.emit('pause');
  }).on('resume', function() {

    return self.emit('resume');
  }).on('open', function(fd) {

    return self.emit('open', fd);
  }).on('close', function() {

    return self.emit('close');
  }).on('end', function() {

    return self.emit('end');
  }).on('error', function(err) {

    return self.emit('error', err);
  });
}
935791
function serverSecurityData(opt) {
	var self = {
		__TYPE__ : MessageType.SC_SECURITY,
		encryptionMethod : new type.UInt32Le(),
		encryptionLevel : new type.UInt32Le() 
	};
	
	return new type.Component(self, opt);
}