Index: olena/ChangeLog
from Giovanni Palma <giovanni(a)lrde.epita.fr>
* tests/utils/tests/md5: Add file
* oln/utils/key.hxx: Add constructor.
* oln/utils/key.hh: Likewise.
* oln/utils/buffer.hxx: Correct code.
* oln/Makefile.am: Add md5 files reference.
+2004-03-19 Giovanni Palma <giovanni(a)lrde.epita.fr>
+
* oln/utils/md5.hh: Add function for md5 calls.
* oln/utils/md5.hxx: Likewise.
Index: olena/oln/Makefile.am
--- olena/oln/Makefile.am Mon, 08 Mar 2004 08:12:15 +0100 palma_g (oln/q/47_Makefile.a
1.3.1.1.1.6.1.7.1.2 640)
+++ olena/oln/Makefile.am Fri, 19 Mar 2004 17:24:16 +0100 palma_g (oln/q/47_Makefile.a
1.3.1.1.1.6.1.7.1.2 640)
@@ -205,6 +205,12 @@
transforms/dwt.hh \
transforms/wavelet_coeffs.hh \
utils/copy.hh \
+ utils/key.hh \
+ utils/key.hxx \
+ utils/md5.hh \
+ utils/md5.hxx \
+ utils/buffer.hh \
+ utils/buffer.hxx \
utils/histogram.hh \
utils/stat.hh \
utils/special_points.hh \
Index: olena/oln/utils/buffer.hxx
--- olena/oln/utils/buffer.hxx Fri, 19 Mar 2004 15:52:57 +0100 palma_g (oln/k/9_buffer.hxx
1.1 644)
+++ olena/oln/utils/buffer.hxx Fri, 19 Mar 2004 16:58:18 +0100 palma_g (oln/k/9_buffer.hxx
1.1 644)
@@ -129,10 +129,6 @@
add(reorder(len2_), false);
add(reorder(len1_), false);
- std::cout << len2_ << len1_<< std::endl;
- std::cout << (*this)[data_.size()-2] << (*this)[data_.size()-1] <<
std::endl;
- std::cout << data_.size() - 1<< std::endl;
- std::cout << (*this)[14]<< std::endl;
length_appended_ = true;
};
Index: olena/oln/utils/key.hxx
--- olena/oln/utils/key.hxx Fri, 19 Mar 2004 15:52:57 +0100 palma_g (oln/k/11_key.hxx 1.1
644)
+++ olena/oln/utils/key.hxx Fri, 19 Mar 2004 17:05:24 +0100 palma_g (oln/k/11_key.hxx 1.1
644)
@@ -36,6 +36,14 @@
data_[i] = data[i];
}
+// Ctor implementation.
+inline
+key::key(const value_type *data)
+{
+ for (unsigned i = 0; i < 16; ++i)
+ data_[i] = data[i];
+}
+
// [] operator implementation
inline
key::value_type &key::operator[](unsigned i)
Index: olena/oln/utils/key.hh
--- olena/oln/utils/key.hh Fri, 19 Mar 2004 15:52:57 +0100 palma_g (oln/k/12_key.hh 1.1
644)
+++ olena/oln/utils/key.hh Fri, 19 Mar 2004 17:11:43 +0100 palma_g (oln/k/12_key.hh 1.1
644)
@@ -52,6 +52,14 @@
explicit key(const std::vector<value_type> &data);
/*!
+ ** \brief Constructor used to initialize the key.
+ **
+ ** \pre There must at least 16 elements in data.
+ ** \arg data Inuput data.
+ */
+ explicit key(const value_type *data);
+
+ /*!
** \brief [] operator.
**
** \return the ith byte of the key.
@@ -95,8 +103,10 @@
*/
friend std::ostream &operator<<(std::ostream &stream, const key
&k)
{
- for (unsigned i = 0; i < 16; ++i)
- stream << std::hex << k[i];
+ stream << "{";
+ for (unsigned i = 0; i < 15; ++i)
+ stream << "0x" << std::hex << k[i] << ",
";
+ stream << "0x" << std::hex << k[15] << "}";
return stream;
}
Index: olena/tests/utils/tests/md5
--- olena/tests/utils/tests/md5 Fri, 19 Mar 2004 17:28:06 +0100 palma_g ()
+++ olena/tests/utils/tests/md5 Fri, 19 Mar 2004 17:23:10 +0100 palma_g (oln/k/15_md5
644)
@@ -0,0 +1,51 @@
+// -*- c++ -*-
+
+#include <ntg/int.hh>
+#include <oln/basics2d.hh>
+#include <oln/utils/md5.hh>
+
+#include <iostream>
+
+#include "check.hh"
+#include "data.hh"
+
+using namespace oln;
+using namespace ntg;
+using namespace utils;
+
+#define OK_OR_FAIL \
+ std::cout << "OK" << std::endl; \
+ else \
+ { \
+ std::cout << "FAIL" << std::endl; \
+ fail = true; \
+ }
+
+bool
+check()
+{
+ bool fail = false;
+ oln::utils::key::value_type data_ppm[16] = {0x47, 0xa5, 0xb6, 0xa2, 0xc8,
+ 0xf1, 0x4d, 0xb8, 0x90, 0x67,
+ 0xaa, 0x19, 0x3d, 0x43, 0xb6,
+ 0xe0};
+ key lena_ppm(data_ppm);
+ oln::utils::key::value_type data_pgm[16] = {0xc7, 0xe4, 0x4, 0x4c, 0x32,
+ 0x1d, 0x2e, 0x3e, 0x5c, 0xbf,
+ 0x89, 0x8d, 0x3f, 0x94, 0x16,
+ 0xd5};
+ key lena_pgm(data_pgm);
+
+ image2d<rgb_8> src = load(rdata("lena.ppm"));
+ image2d<int_u8> src2 = load(rdata("lena.pgm"));
+
+
+ std::cout << "MD5 on vectorial images: ";
+ if (lena_ppm == md5(src))
+ OK_OR_FAIL;
+ std::cout << "MD5 on non vectorial images: ";
+ if (lena_pgm == md5(src2))
+ OK_OR_FAIL;
+
+ return fail;
+}
--
Giovanni Palma
EPITA - promo 2005 - membre d'EpX - LRDE
Mob. : +33 (0)6 60 97 31 74