
Index: olena/ChangeLog from Giovanni Palma <giovanni@lrde.epita.fr> * oln/utils/md5.hh: Add function for md5 calls. * oln/utils/md5.hxx: Likewise. +2004-03-19 Giovanni Palma <giovanni@lrde.epita.fr> + * oln/utils/buffer.hxx: Add file. * oln/utils/buffer.hh: Likewise. * oln/utils/key.hh: Likewise. Index: olena/oln/utils/md5.hxx --- olena/oln/utils/md5.hxx Fri, 19 Mar 2004 15:52:57 +0100 palma_g (oln/k/13_md5.hxx 1.1 644) +++ olena/oln/utils/md5.hxx Fri, 19 Mar 2004 16:49:29 +0100 palma_g (oln/k/13_md5.hxx 1.1 644) @@ -281,4 +281,44 @@ step(); return gen_key(); } + + +// md5 implementation. +template <class I> +inline +key md5(const abstract::non_vectorial_image<I> &im) +{ + oln_iter_type(I) p(im); + buffer b; + + for_all(p) + b.add(im[p]); + b.append_padding(); + b.append_length(); + + oln::utils::MD5 md5(b); + return md5.execute(); +} + +// md5 implementation. +template <class I> +inline +key md5(const abstract::vectorial_image<I> &im) +{ + oln_iter_type(I) p(im); + buffer b; + // unsigned nb = + + for_all(p) + { + for (unsigned i = 0; i < ntg_nb_comp(oln_value_type(I)); ++i) + b.add(im[p][i]); + } + b.append_padding(); + b.append_length(); + + oln::utils::MD5 md5(b); + return md5.execute(); +} + #endif // !OLENA_OLN_UTILS_MD5_HXX Index: olena/oln/utils/md5.hh --- olena/oln/utils/md5.hh Fri, 19 Mar 2004 15:52:57 +0100 palma_g (oln/k/14_md5.hh 1.1 644) +++ olena/oln/utils/md5.hh Fri, 19 Mar 2004 16:38:39 +0100 palma_g (oln/k/14_md5.hh 1.1 644) @@ -31,6 +31,8 @@ # include <ntg/all.hh> # include <vector> +# include <oln/core/abstract/image_with_type_with_dim.hh> + # include <oln/utils/key.hh> # include <oln/utils/buffer.hh> @@ -199,6 +201,30 @@ #include <oln/utils/md5.hxx> + /*! + ** \brief Compute The Md5 value of an image. + ** + ** \param I Exact type of the image. + ** + ** \arg im Image to process. + ** + ** Non vectorial image version. + */ + template <class I> + key md5(const abstract::non_vectorial_image<I> &im); + + /*! + ** \brief Compute The Md5 value of an image. + ** + ** \param I Exact type of the image. + ** + ** \arg im Image to process. + ** + ** Vectorial image version. + */ + template <class I> + key md5(const abstract::vectorial_image<I> &im); + } // !utils } // !oln #endif // !OLENA_OLN_UTILS_MD5_HH -- Giovanni Palma EPITA - promo 2005 - membre d'EpX - LRDE Mob. : +33 (0)6 60 97 31 74