code: public static URI createSha1Urn(final InputStream is, 
          final MessageDigest md) throws IOException
          {
          LOG.debug("Creating SHA-1");
          // Note: The size of this array is not the bottleneck.
          final byte[] buffer = new byte[65536];
          int read;
          
          try 
              {
              while ((read = is.read(buffer)) != -1) 
                  {
                  //long start = System.currentTimeMillis();
                  md.update(buffer,0,read);
                  //progress.addInt( read );
                  /*
                  if (SystemUtils.getIdleTime() < MIN_IDLE_TIME) 
                      {
                      long end = System.currentTimeMillis();
                      long interval = end - start;
                      if (LOG.isTraceEnabled())
                          {
                          LOG.trace("Accessed idle time: "+SystemUtils.getIdleTime()+
                              " interval: "+interval);
                          }
                      if (interval > 0)
                          Thread.sleep(interval * 3);
                      else
                          Thread.yield();
                      }
                      */
                   }
              } 
          
          finally 
              {     
              IOUtils.closeQuietly(is);
              }
  
          final byte[] sha1 = md.digest();
  
          LOG.debug("Done creating SHA-1");
          try
              {
              // preferred casing: lowercase "urn:sha1:", uppercase encoded value
              // note that all URNs are case-insensitive for the "urn:<type>:" part,
              // but some MAY be case-sensitive thereafter (SHA1/Base32 is case 
              // insensitive)
              return new URI("urn:sha1:"+Base32.encode(sha1));
              }
          catch (final URISyntaxException e)
              {
              // This should never happen.
              LOG.error("Could not encode SHA-1", e);
              throw new IOException("bad uri: "+Base32.encode(sha1));
              }  
          }
docs: Create a new SHA1 hash URI for the specified {@link InputStream}.
  
  @param is The {@link InputStream} to create the SHA-1 for.
  @param md The {@link MessageDigest} class to use.
  @return The SHA1 hash as a URI.
  @throws IOException If there is an error creating the hash or if the
  specified algorithm cannot be found.