old_contents: # Import nacl libs
  import libnacl
  
  # Import python libs
  import datetime
  import binascii
  
  
  class BaseKey(object):
      '''
      Include methods for key management convenience
      '''
      def hex_sk(self):
          if hasattr(self, 'sk'):
              return libnacl.encode.hex_encode(self.sk)
          else:
              return ''
  
      def hex_pk(self):
          if hasattr(self, 'pk'):
              return libnacl.encode.hex_encode(self.pk)
  
      def hex_vk(self):
          if hasattr(self, 'pk'):
              return libnacl.encode.hex_encode(self.pk)
  
  
  def salsa_key():
      '''
      Generates a salsa2020 key
      '''
      return libnacl.randombytes(libnacl.crypto_secretbox_KEYBYTES)
  
  
  def time_nonce():
      '''
      Generates a safe nonce
  
      The nonce generated here is done by grabbing the 20 digit microsecond
      timestamp and appending 4 random chars
      '''
      nonce = '{0:%Y%m%d%H%M%S%f}{1}'.format(
              datetime.datetime.now(),
              binascii.hexlify(libnacl.randombytes(2)).decode(encoding='UTF-8'))
      return nonce
  
new_contents: # Import nacl libs
  import libnacl
  import libnacl.encode
  
  # Import python libs
  import datetime
  import binascii
  
  
  class BaseKey(object):
      '''
      Include methods for key management convenience
      '''
      def hex_sk(self):
          if hasattr(self, 'sk'):
              return libnacl.encode.hex_encode(self.sk)
          else:
              return ''
  
      def hex_pk(self):
          if hasattr(self, 'pk'):
              return libnacl.encode.hex_encode(self.pk)
  
      def hex_vk(self):
          if hasattr(self, 'pk'):
              return libnacl.encode.hex_encode(self.pk)
  
  
  def salsa_key():
      '''
      Generates a salsa2020 key
      '''
      return libnacl.randombytes(libnacl.crypto_secretbox_KEYBYTES)
  
  
  def time_nonce():
      '''
      Generates a safe nonce
  
      The nonce generated here is done by grabbing the 20 digit microsecond
      timestamp and appending 4 random chars
      '''
      nonce = '{0:%Y%m%d%H%M%S%f}{1}'.format(
              datetime.datetime.now(),
              binascii.hexlify(libnacl.randombytes(2)).decode(encoding='UTF-8'))
      return nonce
  
subject: add libnacl.encode import