Yes, you can use the built-in hashlib
module or the built-in hash
function. Then, chop-off the last eight digits using modulo operations or string slicing operations on the integer form of the hash:
>>> s="she sells sea shells by the sea shore"
>>> # Use hashlib
>>> import hashlib
>>> int(hashlib.sha1(s.encode("utf-8")).hexdigest(), 16) % (10 ** 8)
58097614L
>>> # Use hash()
>>> abs(hash(s)) % (10 ** 8)
82148974
Related Contents:
- Weighted random selection with and without replacement
- Pick N distinct items at random from sequence of unknown length, in only one iteration
- Shuffle an array with python, randomize array item order with python
- Weighted random sample in python
- Find elements of array one nearest to elements of array two
- Binary random array with a specific proportion of ones?
- How can I interleave or create unique permutations of two strings (without recursion)
- Python: Choose random line from file, then delete that line
- Generate random array of floats between a range
- Using numpy to build an array of all combinations of two arrays
- How is Python’s List Implemented?
- How do I create a list of random numbers without duplicates?
- Generate random integers between 0 and 9
- Is there any numpy group by function?
- How to split text without spaces into list of words
- Quick way to upsample numpy array by nearest neighbor tiling [duplicate]
- Numpy matrix to array
- Efficient calculation of Fibonacci series
- Why is Bubble Sort implementation looping forever?
- Numpy random choice to produce a 2D-array with all unique values
- How can one continuously generate and track several random objects with a time delay in pygame? [duplicate]
- heapq with custom compare predicate
- how to split an iterable in constant-size chunks [duplicate]
- Weighted random selection from array
- Numpy: Fix array with rows of different lengths by filling the empty elements with zeros
- Mapping a range of values to another
- Replacing Numpy elements if condition is met
- How to make a multidimension numpy array with a varying row size?
- Force NumPy ndarray to take ownership of its memory in Cython
- Finding index of nearest point in numpy arrays of x and y coordinates
- Numpy – add row to array
- Sampling uniformly distributed random points inside a spherical volume
- How to extend an array in-place in Numpy?
- Index 2D numpy array by a 2D array of indices without loops
- Python program to check matching of simple parentheses
- How to check whether two lists are circularly identical in Python
- How to get a normal distribution within a range in numpy? [duplicate]
- General bars and stars
- Binary search algorithm in python
- How to read an array of integers from single line of input in python3
- how to perform max/mean pooling on a 2d array using numpy
- Mapping a NumPy array in place
- Shuffling NumPy array along a given axis
- Numpy individual element access slower than for lists
- How to convert a 3d numpy array to 2d
- Replace list of list with “condensed” list of list while maintaining order
- Numpy array dimensions
- Numpy: Divide each row by a vector element
- What’s the best way to generate random strings of a specific length in Python?
- How to access a column in a list of lists in python