File: README.python

package info (click to toggle)
tlsh 5.0.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,964 kB
  • sloc: cpp: 9,266; python: 1,643; java: 1,214; sh: 703; javascript: 467; ansic: 54; makefile: 27; sed: 9
file content (69 lines) | stat: -rw-r--r-- 1,732 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
31/May/2019

Thanks to Jayson Pryde for compilation on Windows

To create and test the Python Extension on Windows - see README.windows

==============================================================
06/Jan/2026

To use TLSH for pynndescent

(A) create a virtual environment
$ python3 -m venv .venv
$ source .venv/bin/activate
$ pip install setuptools
$ pip install numpy

(B) follow instructions (1) - (4) below

(C) test it
$ cd py_ext
$ python pynn_test.py

To use pynndescent, we are using byte arrays

import numpy as np
import tlsh

byte_data = bytearray(36)
h1 = tlsh.Tlsh()
h1.fromTlshStr(digest)
h1.toByteArray(byte_data)
numpy_array = np.asarray(memoryview(byte_data), dtype=np.uint8)

NOTE: numpy.asarray() with memoryview: This method also avoids copying data and is highly efficient for bytearray objects.

==============================================================
24/Mar/2018

To make the python version

(1) compile the C++ code
	$./make.sh
(2) build the python version
	$ cd py_ext/
	$ python ./setup.py build
(3) install - possibly - sudo, run as root or administrator
	$ python ./setup.py install
(4) test it
	$ cd ../Testing
	$ ./python_test.sh

==============================================================
17/Oct/2016

Sorry everyone for me breaking the Python implementation of TLSH
The --force option meant that I changed the CMakeLists.txt
And I did not test the Python (I am an algorithm / C++ guy - not really a Python guy).

Anyway - I dug through it and did the steps (1)-(3) above
I fixed setup.py to process the new CMakeLists.txt properly
And now it passes

I am going to incorporate this into the regression test - with a -python option
So that this does not occur again

Sorry once again...