public static int crypto_stream(byte[] c, int clen, byte[] n, int noffset, byte[] k)
	{
		byte[] inv = new byte[16];
		byte[] block = new byte[64];
		
		int coffset = 0;
		
		if (clen == 0)
			return 0;

		for (int i = 0; i < 8; ++i)
			inv[i] = n[noffset + i];
		
		for (int i = 8; i < 16; ++i)
			inv[i] = 0;

		while (clen >= 64)
		{		
			salsa20.crypto_core(c, inv, k, sigma);

			int u = 1;
			
			for (int i = 8; i < 16; ++i)
			{
				u += inv[i]&0xff;
				inv[i] = (byte) u;
				u >>>= 8;
			}

			clen -= 64;
			coffset += 64;
		}

		if (clen != 0)
		{			
			salsa20.crypto_core(block, inv, k, sigma);
			
			for (int i = 0; i < clen; ++i)
				c[coffset + i] = block[i];
		}
		
		return 0;
	}