Builds a proper salt ID.
@param path
@param saltID
@return
777872
private URI buildSaltId(List<String> path, String saltID)
  {
    StringBuilder sb = new StringBuilder("salt:/");

    Iterator<String> itPath = path.iterator();
    while(itPath.hasNext())
    {
      String dir = itPath.next();
      sb.append(pathEscaper.escape(dir));
      if(itPath.hasNext())
      {
        sb.append("/");
      }
    }
    
    sb.append("#").append(fragmentEscaper.escape(saltID));


    URI result;
    try
    {
      result = new URI(sb.toString());
      return result;
    }
    catch (URISyntaxException ex)
    {
      log.error("Could not generate valid ID from path "
        + path.toString() + " and node name " + saltID, ex);
    }
    return null;
  }
1196085
Path makeBlockPath(BlockId id) {
        String filename = id.fileNameString();
        return m_largeQuerySwapPath.resolve(filename);
    }
543073
def _read_conf_file(path):
    '''
    
    '''
    log.debug('Reading configuration from %s', path)
    with salt.utils.files.fopen(path, 'r') as conf_file:
        try:
            conf_opts = salt.utils.yaml.safe_load(conf_file) or {}
        except salt.utils.yaml.YAMLError as err:
            message = 'Error parsing configuration file: {0} - {1}'.format(path, err)
            log.error(message)
            raise salt.exceptions.SaltConfigurationError(message)

        # only interpret documents as a valid conf, not things like strings,
        # which might have been caused by invalid yaml syntax
        if not isinstance(conf_opts, dict):
            message = 'Error parsing configuration file: {0} - conf ' \
                      'should be a document, not {1}.'.format(path, type(conf_opts))
            log.error(message)
            raise salt.exceptions.SaltConfigurationError(message)

        # allow using numeric ids: convert int to string
        if 'id' in conf_opts:
            if not isinstance(conf_opts['id'], six.string_types):
                conf_opts['id'] = six.text_type(conf_opts['id'])
            else:
                conf_opts['id'] = salt.utils.data.decode(conf_opts['id'])
        return conf_opts
807664
def _gen_hash(self, password, salt):
        

        # generate hash
        h = hashlib.sha1()
        h.update(salt)
        h.update(password)
        return h.hexdigest()
1038646
def __hash_and_stat_file(self, path, saltenv='base'):
        '''
        
        '''
        try:
            path = self._check_proto(path)
        except MinionError as err:
            if not os.path.isfile(path):
                log.warning(
                    'specified file %s is not present to generate hash: %s',
                    path, err
                )
                return {}, None
            else:
                ret = {}
                hash_type = self.opts.get('hash_type', 'md5')
                ret['hsum'] = salt.utils.hashutils.get_hash(path, form=hash_type)
                ret['hash_type'] = hash_type
                return ret
        load = {'path': path,
                'saltenv': saltenv,
                'cmd': '_file_hash'}
        return self.channel.send(load)
305435
public int hash(JimfsPath path) {
    int hash = 31;
    hash = 31 * hash + getFileSystem().hashCode();

    final Name root = path.root();
    final ImmutableList<Name> names = path.names();

    if (equalityUsesCanonicalForm) {
      // use hash codes of names themselves, which are based on the canonical form
      hash = 31 * hash + (root == null ? 0 : root.hashCode());
      for (Name name : names) {
        hash = 31 * hash + name.hashCode();
      }
    } else {
      // use hash codes from toString() form of names
      hash = 31 * hash + (root == null ? 0 : root.toString().hashCode());
      for (Name name : names) {
        hash = 31 * hash + name.toString().hashCode();
      }
    }
    return hash;
  }
225366
private static String getSalt(byte[] value) {

        byte[] salt = new byte[Generate.SALT_BYTES];
        System.arraycopy(value, 0, salt, 0, salt.length);
        return ByteArray.toBase64(salt);
    }
967791
public static FacesServletMapping createPrefixMapping(String path)
    {
        FacesServletMapping mapping = new FacesServletMapping();
        mapping.setPrefix(path);
        return mapping;
    }
1201596
def salt_ssh_create_dirs(self):
        
        logger.debug('Creating salt-ssh dirs into: %s', self.settings_dir)
        utils.create_dir(os.path.join(self.settings_dir, 'salt'))
        utils.create_dir(os.path.join(self.settings_dir, 'pillar'))
        utils.create_dir(os.path.join(self.settings_dir, 'etc', 'salt'))
        utils.create_dir(os.path.join(self.settings_dir, 'var', 'cache', 'salt'))
        utils.create_dir(os.path.join(self.settings_dir, 'var', 'log', 'salt'))
1323698
function (password, algorithm, salt) {

            return {
                hash: this.createHash(password, algorithm, salt),
                loginAttempts: 0,
                loginBlocked: null
            }

        }
521989
def gen_salt(length):
    """"""
    if length <= 0:
        raise ValueError('requested salt of length <= 0')
    return ''.join(_sys_rng.choice(SALT_CHARS) for _ in range_type(length))
735358
def load(path):
    '''
    
    '''
    ret = {}
    fmadm = _check_fmadm()
    cmd = '{cmd} load {path}'.format(
        cmd=fmadm,
        path=path
    )
    res = __salt__['cmd.run_all'](cmd)
    retcode = res['retcode']
    result = {}
    if retcode != 0:
        result['Error'] = res['stderr']
    else:
        result = True

    return result
14988
public static byte[] generateSalt() throws NoSuchAlgorithmException {
        SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
        byte[] salt = new byte[8];
        random.nextBytes(salt);
        return salt;
    }
1121960
public static InputStream newInputStream(String path) throws IOException
    {
        if (IOAdapter == null) return new FileInputStream(path);
        return IOAdapter.open(path);
    }
181511
def get(path):
    '''
    
    '''
    file_path = __get_docker_file_path(path)
    if file_path is None:
        return __standardize_result(False,
                                    'Path {} is not present'.format(path),
                                    None, None)
    salt_result = __read_docker_compose_file(file_path)
    if not salt_result['status']:
        return salt_result
    project = __load_project(path)
    if isinstance(project, dict):
        salt_result['return']['valid'] = False
    else:
        salt_result['return']['valid'] = True
    return salt_result
527603
func SaltID(salt, id string, hash HashFunc) string {
	comb := salt + id
	hashVal := hash([]byte(comb))
	return hex.EncodeToString(hashVal)
}
274238
def ext_pillar(minion_id, pillar, *args, **kwargs):
    '''
    
    '''
    # Node definitions path will be retrieved from args (or set to default),
    # then added to 'salt_data' dict that is passed to the 'get_pillars'
    # function. The dictionary contains:
    #     - __opts__
    #     - __salt__
    #     - __grains__
    #     - __pillar__
    #     - minion_id
    #     - path
    #
    # If successful, the function will return a pillar dict for minion_id.

    # If path has not been set, make a default
    for i in args:
        if 'path' not in i:
            path = '/srv/saltclass'
            args[i]['path'] = path
            log.warning('path variable unset, using default: %s', path)
        else:
            path = i['path']

    # Create a dict that will contain our salt dicts to pass it to reclass
    salt_data = {
        '__opts__': __opts__,
        '__salt__': __salt__,
        '__grains__': __grains__,
        '__pillar__': pillar,
        'minion_id': minion_id,
        'path': path
    }

    return sc.get_pillars(minion_id, salt_data)