Skip to content

Instantly share code, notes, and snippets.

@CjS77
Created March 12, 2019 09:05
Show Gist options
  • Save CjS77/9dc02ef008522ce0a7d5357551010726 to your computer and use it in GitHub Desktop.
Save CjS77/9dc02ef008522ce0a7d5357551010726 to your computer and use it in GitHub Desktop.
Proposed RAID_ID algorithm
# -*- coding: utf-8 -*-
from hashlib import blake2b
import bitcoin.base58 as base58
import string
import random
def create_raid(fqdn = None, prefix=0x62):
s = fqdn if fqdn else "NO_FQDN"
b = bytes(map(ord, s))
hash = blake2b(b, digest_size=10).digest()
return base58.encode(bytes([prefix]) + hash)
def randomString(stringLength=10):
"""Generate a random string of fixed length """
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(stringLength))
for s in [None, "disney.com", "www.tarilabs.com", "tickets.bigneon.com"]:
print("%-20s => %s" % (s, create_raid(s)))
@CjS77
Copy link
Author

CjS77 commented Mar 12, 2019

I think it was pip install python-bitcoinlib if you're using conda, otherwise pip3 install python-bitcoinlib

@hansieodendaal
Copy link

Perfect! It worked. thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment