1#!/usr/bin/python 2 3# Copyright (C) Internet Systems Consortium, Inc. ("ISC") 4# 5# SPDX-License-Identifier: MPL-2.0 6# 7# This Source Code Form is subject to the terms of the Mozilla Public 8# License, v. 2.0. If a copy of the MPL was not distributed with this 9# file, you can obtain one at https://mozilla.org/MPL/2.0/. 10# 11# See the COPYRIGHT file distributed with this work for additional 12# information regarding copyright ownership. 13 14# catzhash.py: generate the SHA-1 hash of a domain name in wire format. 15# 16# This can be used to determine the label to use in a catalog zone to 17# represent the specified zone. For example, the zone 18# "domain.example" can be represented in a catalog zone called 19# "catalog.example" by adding the following record: 20# 21# 5960775ba382e7a4e09263fc06e7c00569b6a05c.zones.catalog.example. \ 22# IN PTR domain.example. 23# 24# The label "5960775ba382e7a4e09263fc06e7c00569b6a05c" is the output of 25# this script when run with the argument "domain.example". 26 27import sys 28import hashlib 29import dns.name 30 31if len(sys.argv) < 2: 32 print("Usage: %s name" % sys.argv[0]) 33 34NAME = dns.name.from_text(sys.argv[1]).to_wire() 35print(hashlib.sha1(NAME).hexdigest()) 36