# File lib/dnsruby/resource/DS.rb, line 153
      def DS.from_key(key, digest_type)
# # The key must not be a NULL key.
#    if ((key.flags & 0xc000 ) == 0xc000 )
#       puts "\nCreating a DS record for a NULL key is illegal"
#        return
#    end
# 
#    # Bit 0 must not be set.
#    if (key.flags & 0x8000)
#       puts "\nCreating a DS record for a key with flag bit 0 set " +
#           "to 0 is illegal"
#          return
#    end
# 
    #  Bit 6 must be set to 0 bit 7 must be set to 1
    if (( key.flags & 0x300) != 0x100)
        puts "\nCreating a DS record for a key with flags 6 and 7 not set "+
            "0  and 1 respectively is illegal"
         return
    end
# 
# 
#    if (key.protocol  != 3 )
#       puts "\nCreating a DS record for a non DNSSEC (protocol=3) " +
#           "key is illegal"
#          return
#    end
# 
        digest_type = get_digest_type(digest_type)
        #  Create a new DS record from the specified key
        ds = RR.create(:name => key.name, :type => "DS", :ttl => key.ttl,
                      :key_tag => key.key_tag,
                     :digest_type => digest_type, :algorithm => key.algorithm)

        ds.digestbin = ds.digest_key(key, digest_type)
        ds.digest = ds.digestbin.unpack("H*")[0]
        return ds
      end