Downloads information about a sample using a given hash.

        :param samplehash: hash to search for. Has to be either md5, sha1 or sha256
        :type samplehash: str
        :returns: Dictionary of results
        :rtype: dict
433077
def get_sample(self, samplehash):
        
        apiurl = '/rest/sample/'
        if len(samplehash) == 32:  # MD5
            apiurl += 'md5/'
        elif len(samplehash) == 40:  # SHA1
            apiurl += 'sha1/'
        elif len(samplehash) == 64:  # SHA256
            apiurl += 'sha256/'
        else:
            raise UnknownHashTypeError('Sample hash has an unknown length.')

        res = self.session.get(self.url + apiurl + samplehash)
        if res.status_code == 200:
            return json.loads(res.text)
        else:
            raise BadResponseError('Response from VMRay was not HTTP 200.'
                                   ' Responsecode: {}; Text: {}'.format(res.status_code, res.text))
1052305
def hash(self):
        """"""
        if self._hash is None:
            tohash = [self.path.name]
            # Hash a maximum of ~1MB of the hdf5 file
            tohash.append(hashfile(self.path, blocksize=65536, count=20))
            self._hash = hashobj(tohash)
        return self._hash
954150
def _sample_type(self, sample=None):
        
        data = {}
        sampletype = sample.getSampleType() if sample else None
        if sampletype:
            data = {'obj': sampletype,
                    'id': sampletype.id,
                    'title': sampletype.Title(),
                    'url': sampletype.absolute_url()}
        return data
84628
def get_image_hash(image):
    '''
    
    '''
    md5 = hashlib.md5()
    try:
        for chunk in image.file.chunks():
            md5.update(chunk)
        return md5.hexdigest()
    # this should only occur in tests
    except ValueError:
        # see link below for why we try not to use .open()
        # https://docs.djangoproject.com/en/1.9/ref/files/uploads/#django.core.files.uploadedfile.UploadedFile.chunks  # noqa
        image.file.open()

        for chunk in image.file.chunks():
            md5.update(chunk)
        return md5.hexdigest()
    finally:
        image.file.close()
1062502
def get(self, multihash, **kwargs):
        
        args = (multihash,)
        return self._client.download('/get', args, **kwargs)
1373827
def fetchByExample(self, exampleDict, batchSize, rawResults = False, **queryArgs) :
        """"""
        return self.simpleQuery('by-example', rawResults, example = exampleDict, batchSize = batchSize, **queryArgs)
1169113
def get_sha_blob(self):
        
        r = requests.get(self.api_url, auth=self.get_auth_details())
        try:
            return r.json()['sha']
        except KeyError:
            return None
906599
def get_hashhash(self, username):
        
        return hashlib.sha256(
            self.users.get_hash(username)
        ).hexdigest()
197493
def get_subhash(hash):
    
    idx = [0xe, 0x3, 0x6, 0x8, 0x2]
    mul = [2, 2, 5, 4, 3]
    add = [0, 0xd, 0x10, 0xb, 0x5]

    b = []
    for i in range(len(idx)):
        a = add[i]
        m = mul[i]
        i = idx[i]
        t = a + int(hash[i], 16)
        v = int(hash[t:t + 2], 16)
        b.append(('%x' % (v * m))[-1])

    return ''.join(b)
1349141
def fetch(self):
        
        params = values.of({})

        payload = self._version.fetch(
            'GET',
            self._uri,
            params=params,
        )

        return SampleInstance(
            self._version,
            payload,
            assistant_sid=self._solution['assistant_sid'],
            task_sid=self._solution['task_sid'],
            sid=self._solution['sid'],
        )
78380
def sample(self, hash, limit=None, offset=None):
        ''''''

        uri = self._uris['sample'].format(hash)
        params = {'limit': limit, 'offset': offset}

        return self.get_parse(uri, params)
808654
def _get_content_hash(self):  # type: () -> str
        
        content = self._local_config

        relevant_content = {}
        for key in self._relevant_keys:
            relevant_content[key] = content.get(key)

        content_hash = sha256(
            json.dumps(relevant_content, sort_keys=True).encode()
        ).hexdigest()

        return content_hash
613104
def is_hash(fhash):
    """"""

    # Intentionally doing if/else statement for ease of testing and reading
    if re.match(re_md5, fhash):
        return True
    elif re.match(re_sha1, fhash):
        return True
    elif re.match(re_sha256, fhash):
        return True
    elif re.match(re_sha512, fhash):
        return True
    elif re.match(re_ssdeep, fhash):
        return True
    else:
        return False
770710
def _get_hash(self, name, operation, create=False):
        
        return self._get_by_type(name, operation, create, b'hash', {})
64671
def _hash_url(self, url):
        

        if isinstance(url, six.text_type):
            url = url.encode('utf-8')

        return hashlib.md5(url).hexdigest()
240193
def EQL?(sample) 
      @it.eql?(sample) && sample.eql?(@it) && (@it.hash == sample.hash) &&
      ({@it => true}.has_key? sample)
    end
299295
def _get_hash_by_shell():
    '''
    
    '''
    id_ = __opts__.get('id', '')
    id_hash = None
    py_ver = sys.version_info[:2]
    if py_ver >= (3, 3):
        # Python 3.3 enabled hash randomization, so we need to shell out to get
        # a reliable hash.
        id_hash = __salt__['cmd.run']([sys.executable, '-c', 'print(hash("{0}"))'.format(id_)],
                                      env={'PYTHONHASHSEED': '0'})
        try:
            id_hash = int(id_hash)
        except (TypeError, ValueError):
            log.debug('Failed to hash the ID to get the server_id grain. Result of hash command: %s', id_hash)
            id_hash = None
    if id_hash is None:
        # Python < 3.3 or error encountered above
        id_hash = hash(id_)

    return abs(id_hash % (2 ** 31))