public string Compress(int[] data, int algorithm = 0) { if (data.Length > 0) { ProcessSubfingerprint((uint)data[0]); for (int i = 1; i < data.Length; i++) { ProcessSubfingerprint((uint)data[i] ^ (uint)data[i - 1]); } } int length = data.Length; m_result = new List<byte>(); m_result.Add((byte)((int)algorithm & 255)); m_result.Add((byte)((length >> 16) & 255)); m_result.Add((byte)((length >> 8) & 255)); m_result.Add((byte)((length) & 255)); WriteNormalBits(); WriteExceptionBits(); return Base64.ByteEncoding.GetString(m_result.ToArray()); }
public void TestTwoItems() { FingerprintCompressor compressor = new FingerprintCompressor(); int[] fingerprint = { 1, 0 }; string value = compressor.Compress(fingerprint); byte[] expected = { 0, 0, 0, 2, 65, 0 }; byte[] actual = Base64.ByteEncoding.GetBytes(value); CollectionAssert.AreEqual(actual, expected); }