资源简介
md5散列函数,用matlab实现的源代码
代码片段和文件信息
function y = md5( a1 a2 a3 );
%MD5 verifies or generates a signature using the md5 algorithm.
% MD5( M ) or MD5( M 0 ) returns a message digest (signature)
% from the matrix M. Currently the classes double and char are supported.
%
% MD5( M 1 ) generates the digest from a file. M must be a char
% array with the filename/filepath.
%
% You can also give a signature as the last argument. In this case the
% generated signature will be compared against the given. Returns 0 or 1.
% Example: MD5( M 1 ‘7dea362b3fac8e00956a4952a3d4f474‘ );
%
% Md5 is actually not intended to work with large files (> 5 MB see notes)
% but is really comfortable to process directly matlab matrices.
% Notes: o There are more hashing routines that could be implemented
% eg. CRC Adler Haval SHA RMD...
% o There‘s a problem with incremental file reading. As a workaround
% I had to load the whole file into the memory. I tested with a 50 MB
% file but though it worked well I should fix this problem if there‘s
% a need to process large files.
% o For questions/comments/requests: support@treetron.ch.
%
% Credits: I used a freeware library with different hash algorithms. It‘s from
% Alex? (Ritlabs) and was downloaded from Torrys. Thanks a lot.
% Built with Borland Delphi.
%
% License: You may use and distribute md5 free of charge for commercial and
% non-commercial use. Please don‘t modify this notice. Before using this
% routine you have to accept the disclaimer of warranty below.
%
% Warranty: md5 is supplied as is. The author disclaims all warranties
% expressed or implied including without limitation the warranties of
% merchantability and of fitness for any purpose. The author assumes no
% liability for damages direct or consequential which may result from the
% use of md5.
%
% Author: Hans-Peter Suter
% Revision: 0.7
% Date: 25.7.2003
%
% Copyright: Copyright (c) 2003 Treetron GmbH.
% All rights reserved.
if nargin == 3
b1 = a1; % matrix
b2 = a2; % isFile
b3 = a3; % signature
elseif nargin == 2
if isa( a2 ‘char‘ )
b1 = a1;
b2 = 0;
b3 = a2;
else
b1 = a1;
b2 = a2;
b3 = [];
end
elseif nargin == 1
b1 = a1;
b2 = 0;
b3 = [];
else
error( ‘3 arguments required‘ );
end;
% some checks
if ~isempty( b3 )
if ~isa( b3 ‘char‘ )
error( ‘signature must be a char array‘ );
end
if length( b3 ) ~= 32
error( ‘signature must have 32 chars‘ );
end
end
if ~(isa( b1 ‘char‘ ) | isa( b1 ‘double‘ ))
error( ‘value/filename must be a double or char array‘ );
end
if ~(b2 == 0 | b2 == 1)
error( ‘isFile must be 0 or 1‘ );
end
% call dll
if isempty( b3 )
y = md5dll( b1 b2 );
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3041 2003-07-25 23:32 md5.m
文件 176640 2003-07-25 22:46 md5DLL.dll
文件 4590 2003-07-25 23:21 md5test.m
文件 582 2003-07-25 18:18 testfile.txt
- 上一篇:pid运算电路仿真文件Multisim文件
- 下一篇:热力系统计算模型
相关资源
- 热力系统计算模型
- 图像分割 直方图阈值双峰法的matlab实
- Matlab模糊聚类算法实现
- 带通滤波器matlab程序
- EEMD总体经验模式分解算法matlab程序
- 卷积码编译码matlab仿真
- matlab FastICA工具箱111010
- 用Matlab实现分支定界法求解整数线性
- GUI设计MATLAB
- black scholes方程式源代码
- matlab实现otsu算法
- DE算法 MATLAB程序
- matlab计算卫星位置及运行速度
- 光孤子通信matlab仿真程序
- 双边滤波bilateral filter matlab代码
- maple toolbox for matlab v13破解文件
- k均值聚类算法MATLAB程序及注释
- pso优化BP的MATLAB代码
- LEACH协议仿真
- 基于MATLAB的LQR控制器设计方法研究
- 用matlab画包络图的
- 蒙特卡罗法模拟matlab源程序
- 生成干涉图的MATLAB程序
- 压缩感知 OMP重构一维二维信号matlab仿
- 常见傅里叶变换matlab代码
- 多服务台混合制排队论
- 广义线性模型的matlab代码
- matlab导入三维raw格式图像
- LBP纹理特征官方MATLAB代码和测试用例
- 蒙特卡洛模拟法及其Matlab案例
评论
共有 条评论