code: def gen_hash(crypt_salt=None, password=None, algorithm='sha512'):
      '''
      Generate /etc/shadow hash
      '''
      if not HAS_CRYPT:
          raise SaltInvocationError('No crypt module for windows')
  
      hash_algorithms = dict(
          md5='$1$', blowfish='$2a$', sha256='$5$', sha512='$6$'
      )
      if algorithm not in hash_algorithms:
          raise SaltInvocationError(
              'Algorithm \'{0}\' is not supported'.format(algorithm)
          )
  
      if password is None:
          password = secure_password()
  
      if crypt_salt is None:
          crypt_salt = secure_password(8)
  
      crypt_salt = hash_algorithms[algorithm] + crypt_salt
  
      return crypt.crypt(password, crypt_saltf gen_hash(crypt_salt=None, password=None, algorithm='sha512'):
      '''
      Generate /etc/shadow hash
      '''
      if not HAS_CRYPT:
          raise SaltInvocationError('No crypt module for windows')
  
      hash_algorithms = dict(
          md5='$1$', blowfish='$2a$', sha256='$5$', sha512='$6$'
      )
      if algorithm not in hash_algorithms:
          raise SaltInvocationError(
              'Algorithm \'{0}\' is not supported'.format(algorithm)
          )
  
      if password is None:
          password = secure_password()
  
      if crypt_salt is None:
          crypt_salt = secure_password(8)
  
      crypt_salt = hash_algorithms[algorithm] + crypt_salt
  
      return crypt.crypt(password, crypt_salt)
docs: Generate /etc/shadow hash