def split_hash(hashed):
    """Split the hashed password into it's components.
    
    Returns a tuple with the hash name, cost and salt.
        
        >>> split_hash('dsha512$13$mysalt$myhash')
        ('dsha512', 13, 'mysalt')
        >>> split_hash('bcrypt$06$mysaltyhash')
        ('bcrypt', 6, 'mysaltyhash')
    
    """
    lhashed = hashed.split('$')
    if len(lhashed) < 3:
        raise ValueError
    return lhashed[0], int(lhashed[1]), lhashed[2]
