public static Torrent create(File source, String announce, String createdBy)
		throws NoSuchAlgorithmException, IOException {
		logger.info("Creating torrent for " + source.getName() + "...");

		Map<String, BEValue> torrent = new HashMap<String, BEValue>();
		torrent.put("announce", new BEValue(announce));
		torrent.put("creation date", new BEValue(new Date().getTime()));
		torrent.put("created by", new BEValue(createdBy));

		Map<String, BEValue> info = new TreeMap<String, BEValue>();
		info.put("length", new BEValue(source.length()));
		info.put("name", new BEValue(source.getName()));
		info.put("piece length", new BEValue(Torrent.PIECE_LENGTH));
		info.put("pieces", new BEValue(Torrent.hashPieces(source),
					Torrent.BYTE_ENCODING));
		torrent.put("info", new BEValue(info));

		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		BEncoder.bencode(new BEValue(torrent), baos);
		return new Torrent(baos.toByteArray());
	}