• PUDN用户
    了解作者
  • matlab
    开发工具
  • 19KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 3
    下载次数
  • 2014-08-01 13:54
    上传日期
this is the the code of DES algorithm in matlab
des-algo-in-mat-lab.rar
  • des algo in mat lab.docx
    22KB
内容介绍
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"> <meta name="generator" content="pdf2htmlEX"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <link rel="stylesheet" href="https://static.pudn.com/base/css/base.min.css"> <link rel="stylesheet" href="https://static.pudn.com/base/css/fancy.min.css"> <link rel="stylesheet" href="https://static.pudn.com/prod/directory_preview_static/622b8dee3d2fbb0007120748/raw.css"> <script src="https://static.pudn.com/base/js/compatibility.min.js"></script> <script src="https://static.pudn.com/base/js/pdf2htmlEX.min.js"></script> <script> try{ pdf2htmlEX.defaultViewer = new pdf2htmlEX.Viewer({}); }catch(e){} </script> <title></title> </head> <body> <div id="sidebar" style="display: none"> <div id="outline"> </div> </div> <div id="pf1" class="pf w0 h0" data-page-no="1"><div class="pc pc1 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://static.pudn.com/prod/directory_preview_static/622b8dee3d2fbb0007120748/bg1.jpg"><div class="c x0 y1 w2 h2"><div class="t m0 x1 h3 y2 ff1 fs0 fc0 sc0 ls0 ws0">Des algo in matlab</div><div class="t m0 x1 h4 y3 ff2 fs1 fc1 sc0 ls0 ws0">function [varargout] = DES(input64,mode,key)</div><div class="t m0 x1 h4 y4 ff2 fs1 fc1 sc0 ls0 ws0">%DES: Data Encryption Standard</div><div class="t m0 x1 h4 y5 ff2 fs1 fc1 sc0 ls0 ws0">% Encrypt/Decrypt a 64-bit message using a 64-bit key using the Feistel Network</div><div class="t m0 x1 h4 y6 ff2 fs1 fc1 sc0 ls0 ws0">% -------------------------------------------------------------------------</div><div class="t m0 x1 h4 y7 ff2 fs1 fc1 sc0 ls0 ws0">% Inputs: </div><div class="t m0 x1 h4 y8 ff2 fs1 fc1 sc0 ls0 ws0">% input64 = a 64-bit message </div><div class="t m0 x1 h4 y9 ff2 fs1 fc1 sc0 ls0 ws0">% mode = either 'ENC' encryption or 'DEC' decryption (default 'ENC')</div><div class="t m0 x1 h4 ya ff2 fs1 fc1 sc0 ls0 ws0">% key = a 56/64-bit key (optional under 'ENC', but mandatory under 'DEC')</div><div class="t m0 x1 h4 yb ff2 fs1 fc1 sc0 ls0 ws0">% Outputs:</div><div class="t m0 x1 h4 yc ff2 fs1 fc1 sc0 ls0 ws0">% varargout{1} = output64, a 64-bit message after encryption/decryption</div><div class="t m0 x1 h4 yd ff2 fs1 fc1 sc0 ls0 ws0">% varargout{2} = a 64-bit key, if a 64-bit key is not provided as an input</div><div class="t m0 x1 h4 ye ff2 fs1 fc1 sc0 ls0 ws0">% -------------------------------------------------------------------------</div><div class="t m0 x1 h4 yf ff2 fs1 fc1 sc0 ls0 ws0">% Demos:</div><div class="t m0 x1 h4 y10 ff2 fs1 fc1 sc0 ls0 ws0">% plaintext = round(rand(1,64));</div><div class="t m0 x1 h4 y11 ff2 fs1 fc1 sc0 ls0 ws0">% [ciphertext,key] = DES(plaintext); % Encryption syntex 1</div><div class="t m0 x1 h4 y12 ff2 fs1 fc1 sc0 ls0 ws0">% [ciphertext1,key] = DES(plaintext,'ENC'); % Encryption syntex 2</div><div class="t m0 x1 h4 y13 ff2 fs1 fc1 sc0 ls0 ws0">% deciphertext1 = DES(ciphertext1,'DEC',key);% Decryption syntex</div><div class="t m0 x1 h4 y14 ff2 fs1 fc1 sc0 ls0 ws0">% </div><div class="t m0 x1 h4 y15 ff2 fs1 fc1 sc0 ls0 ws0">% key56 = round(rand(1,56));</div><div class="t m0 x1 h4 y16 ff2 fs1 fc1 sc0 ls0 ws0">% [ciphertext2,key64] = DES(plaintext,'ENC',key56);% Encryption syntex 3 (56-bit key)</div><div class="t m0 x1 h4 y17 ff2 fs1 fc1 sc0 ls0 ws0">% deciphertext2 = DES(ciphertext2,'DEC',key64); % Decryption syntex (64-bit key)</div><div class="t m0 x1 h4 y18 ff2 fs1 fc1 sc0 ls0 ws0">% ciphertext3 = DES(plaintext,'ENC',key64); % Encryption syntex 3 (64-bit key)</div><div class="t m0 x1 h4 y19 ff2 fs1 fc1 sc0 ls0 ws0">% deciphertext3 = DES(ciphertext3,'DEC',key56); % Decryption syntex (56-bit key)</div><div class="t m0 x1 h4 y1a ff2 fs1 fc1 sc0 ls0 ws0">% </div><div class="t m0 x1 h4 y1b ff2 fs1 fc1 sc0 ls0 ws0">% % plot results</div><div class="t m0 x1 h4 y1c ff2 fs1 fc1 sc0 ls0 ws0">% subplot(4,2,1),plot(plaintext),ylim([-.5,1.5]),xlim([1,64]),title('plaintext')</div><div class="t m0 x1 h4 y1d ff2 fs1 fc1 sc0 ls0 ws0">% subplot(4,2,2),plot(ciphertext),ylim([-.5,1.5]),xlim([1,64]),title('ciphertext')</div><div class="t m0 x1 h4 y1e ff2 fs1 fc1 sc0 ls0 ws0">% subplot(4,2,3),plot(deciphertext1),ylim([-.5,1.5]),xlim([1,64]),title('deciphertext1')</div><div class="t m0 x1 h4 y1f ff2 fs1 fc1 sc0 ls0 ws0">% subplot(4,2,4),plot(ciphertext1),ylim([-.5,1.5]),xlim([1,64]),title('ciphertext1')</div><div class="t m0 x1 h4 y20 ff2 fs1 fc1 sc0 ls0 ws0">% subplot(4,2,5),plot(deciphertext2),ylim([-.5,1.5]),xlim([1,64]),title('deciphertext2')</div><div class="t m0 x1 h4 y21 ff2 fs1 fc1 sc0 ls0 ws0">% subplot(4,2,6),plot(ciphertext2),ylim([-.5,1.5]),xlim([1,64]),title('ciphertext2')</div><div class="t m0 x1 h4 y22 ff2 fs1 fc1 sc0 ls0 ws0">% subplot(4,2,7),plot(deciphertext3),ylim([-.5,1.5]),xlim([1,64]),title('deciphertext3')</div><div class="t m0 x1 h4 y23 ff2 fs1 fc1 sc0 ls0 ws0">% subplot(4,2,8),plot(ciphertext3),ylim([-.5,1.5]),xlim([1,64]),title('ciphertext3')</div><div class="t m0 x1 h4 y24 ff2 fs1 fc1 sc0 ls0 ws0">% -------------------------------------------------------------------------</div><div class="t m0 x1 h4 y25 ff2 fs1 fc1 sc0 ls0 ws0">% NOTE: </div><div class="t m0 x1 h4 y26 ff2 fs1 fc1 sc0 ls0 ws0">% 1. If a 64-bit key is provided, then its bit parities will be checked. If</div><div class="t m0 x1 h4 y27 ff2 fs1 fc1 sc0 ls0 ws0">% a 56-bit key is provided, then it is automatically added 8 partity</div><div class="t m0 x1 h4 y28 ff2 fs1 fc1 sc0 ls0 ws0">% checking bits. However, the 8 parity bits are never used in</div><div class="t m0 x1 h4 y29 ff2 fs1 fc1 sc0 ls0 ws0">% DES encryption/decryption process. They are included just for the </div><div class="t m0 x1 h4 y2a ff2 fs1 fc1 sc0 ls0 ws0">% completeness of a DES implementation. </div><div class="t m0 x1 h4 y2b ff2 fs1 fc1 sc0 ls0 ws0">% 2. Cipher modes are not provided in this simple script. If you are </div><div class="t m0 x1 h4 y2c ff2 fs1 fc1 sc0 ls0 ws0">% interested or do not know what does cipher modes mean, please go to page</div><div class="t m0 x1 h4 y2d ff2 fs1 fc1 sc0 ls0 ws0">% http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation</div><div class="t m0 x1 h4 y2e ff2 fs1 fc1 sc0 ls0 ws0">% for details. Please keep in mind that selecting an inappropriate working</div><div class="t m0 x1 h4 y2f ff2 fs1 fc1 sc0 ls0 ws0">% mode may extremely weaken the security of your messages.</div><div class="t m0 x1 h4 y30 ff2 fs1 fc1 sc0 ls0 ws0">% 3. A general description of DES can be found at its wiki page:</div><div class="t m0 x1 h4 y31 ff2 fs1 fc1 sc0 ls0 ws0">% http://en.wikipedia.org/wiki/Data_Encryption_Standard</div><div class="t m0 x1 h4 y32 ff2 fs1 fc1 sc0 ls0 ws0">% The detailed cryptographical primitives can be found under the page:</div><div class="t m0 x1 h4 y33 ff2 fs1 fc1 sc0 ls0 ws0">% http://en.wikipedia.org/wiki/DES_supplementary_material</div><div class="t m0 x1 h4 y34 ff2 fs1 fc1 sc0 ls0 ws0">% If you want to speed-up the DES code here, you can simply store these</div><div class="t m0 x1 h4 y35 ff2 fs1 fc1 sc0 ls0 ws0">% primitives in memory and call them when you need. </div><div class="t m0 x1 h4 y36 ff2 fs1 fc1 sc0 ls0 ws0">% -------------------------------------------------------------------------</div><div class="t m0 x1 h4 y37 ff2 fs1 fc1 sc0 ls0 ws0">% By Yue (Rex) Wu</div><div class="t m0 x1 h4 y38 ff2 fs1 fc1 sc0 ls0 ws0">% ECE Dept @ Tufts Univ.</div></div></div><div class="pi" data-data='{"ctm":[1.568627,0.000000,0.000000,1.568627,0.000000,0.000000]}'></div></div> </body> </html>
评论
    相关推荐
    • DES.rar
      可实现matlab的64位输入DES加密过程
    • des3.rar
      3des加密代码,使用MATLAB语言,可输入8字节明文
    • matlab des算法
      matlab编的des 代码不是很复杂 逻辑还好
    • matlab code for 3des
      利用DES算法(包括ECB和CBC模式)加解密BMP图像 George Marsaglia的“The mother”随机数生成代码,称循环周期达2^250,可以通过ts检验,适用于大规模仿真。 源码已进行类封装。测试程序直接产生可用于matlab的m...
    • DES matlab源码
      DES密码算法的matlab源码及测试样例,调试通过能运行。
    • DES密码的matlab实现
      这是用matlab写的DES代码,自己写完了,运行出来就没管,逻辑还算清楚,可以看下
    • 基于Matlab实现的DES加密
      基于Matlab实现的DES加密方法代码。直接运行后输入函数名称DESDECP(a,b,n),其中a,b分别是16进制的明文字符串和密钥,n为1表示加密,为其他数字表示解密。就可以进行DES加密和解密。
    • DES.zip
      DES分组加密以及解密算法的matlab实现
    • DES.zip
      数据加密标准的MATLAB实现方法 代码
    • des.rar
      des加密代码,使用MATLAB语言,可输入8字节明文