# File lib/Dnsruby/resource/TSIG.rb, line 41
      def generate(m)
        if (!@time_signed)
          time_signed=Time.now
        end
        hmac = nil
        if (@algorithm == HMAC_MD5)
          hmac = Digest::MD5.new
        elsif (@algorithm == HMAC_SHA1)
          hmac=Digest::SHA1.new
        elsif (@algorithm == HMAC_SHA256)
          hmac=Digest::SHA256.new
        end
        hmac.update(@key)

        s=""
        @key.length.times do |i|
          s << @key[i].to_s + ","
        end
        
        print "key : #{s}\n"
        
        b = m.encode
        s=""
        b.length.times do |i|
          s << b[i].to_s + ","
        end
        print "encoded message : #{s}\n"
        
# Digest the message
        if (hmac)
          hmac.update(b) # @TODO@ b is RENDERED MESSAGE!! NOT m.encode!
# Dnsjava has render method for messages
# pnet-dns signs message during encoding process.
        end
        
        data = sig_data        
        s=""
        
        data.length.times do |i|
          s << data[i].to_s + ","
        end
        
        print "encoded TSIG : #{s}\n"
        hmac.update(data)
        
        @mac = hmac.digest
        @mac_size = @mac.length
        
        s=""
        
        @mac.length.times do |i|
          s << @mac[i].to_s + ","
        end
          print "hmac : #{s}\n"
        
      end