Check if it could make sense to use any of the following ideas - https://github.com/jermp/sshash - https://github.com/shenwei356/unikmer