Mercurial > octave
view scripts/deprecated/md5sum.m @ 20913:69489c064cb7
New function hash to calculate MD{2/4/5} and SHA{1,244,256,384,512} hash values.
* bootstrap.conf: include needed GNULIB functions.
* libinterp/dldfcn/hash.cc: new hash value calculating function.
* libinterp/dldfcn/module-files: add hash.cc to build system.
* scripts/deprecated/md5sum.m: new function perserving interface as md5sum.cc.
* scripts/deprecated/module.mk: add md5sum.m to build system.
* libinterp/corefcn/md5sum.cc: removed and replaced by m-file.
* libinterp/corefcn/module.mk: removed md5sum.cc from build system.
* liboctave/util/oct-md5.h: removed unneeded interface header.
* liboctave/util/oct-md5.cc: removed unneeded interface code.
* liboctave/util/module.mk: removed oct-md5.h and oct-md5.cc from build system.
* NEWS: add hash to new functions for 4.2.
* doc/interpreter/system.txi: replace md5sum with hash in the manual.
* scripts/miscellaneous/warning_ids.m: removed orphaned entry.
author | Kai T. Ohlhus <k.ohlhus@gmail.com> |
---|---|
date | Wed, 16 Dec 2015 21:57:32 +0100 |
parents | |
children | 2b8447888e0a |
line wrap: on
line source
## Copyright (C) 2007-2015 David Bateman ## ## This file is part of Octave. ## ## Octave is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## Octave is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- ## @deftypefn {} {} md5sum (@var{file}) ## @deftypefnx {} {} md5sum (@var{str}, @var{opt}) ## ## @code{md5sum} is deprecated and will be removed in Octave version 4.6. ## For equivalent functionality replace calls like @code{md5sum (@var{file})} ## with: ## ## @example ## hash (\"md5\", fileread (@var{file})) ## @end example ## ## And calls like @code{md5sum (@var{str}, true)} with: ## ## @example ## hash (\"md5\", fileread (@var{str})) ## @end example ## ## Calculate the MD5 sum of the file @var{file}. ## ## If the second parameter @var{opt} exists and is true, then calculate the MD5 ## sum of the string @var{str}. ## ## @seealso{hash,fileread} ## @end deftypefn function r = md5sum (str, opt) persistent warned = false; if (! warned) warned = true; warning ("Octave:deprecated-function", "md5sum is obsolete and will be removed from a future version of Octave, please use hash instead"); endif if (nargin == 1) r = hash ("md5", fileread (str)); elseif ((nargin == 2) && isbool (opt) && isscalar (opt) && (opt == true)) r = hash ("md5", str); else print_usage (); endif endfunction %!assert (md5sum ("abc\0", true), "147a664a2ca9410911e61986d3f0d52a"); %!test %! tfile = tempname (); %! fid = fopen (tfile, "wb"); %! fwrite (fid, "abc\0"); %! fclose (fid); %! assert (md5sum (tfile), "147a664a2ca9410911e61986d3f0d52a"); %! unlink (tfile); %!error md5sum ();