フィルターのクリア

How to modify narginchk in DES matlab code

1 回表示 (過去 30 日間)
sadiqa ilyas
sadiqa ilyas 2019 年 11 月 16 日
コメント済み: sadiqa ilyas 2019 年 11 月 19 日
I have downloaded DES code from file exchange and try to modify it a bit but it gives error which I cannot figure out whats wrong with hit. Here is the part of the code
function [varargout] = DES(~,~)
%DES: Data Encryption Standard
% Encrypt/Decrypt a 64-bit message using a 64-bit key using the Feistel Network
% -------------------------------------------------------------------------
% Inputs:
input64 = '1234567890123456789012345678901234567890123456789012345678901234' ;
mode = 'ENC';
key ='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
Outputs:
% varargout{1} = output64, a 64-bit message after encryption/decryption
% varargout{2} = a 64-bit key, if a 64-bit key is not provided as an input
% -------------------------------------------------------------------------
% Demos:
0. Initialization %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 0.1 check input
%error(nargchk(1,3,nargin));
narginchk(1,3);
switch nargin
case 1
narginchk(1,3); error at this line.
>> DES
Error using DES (line 64)
Not enough input arguments.
....

採用された回答

Walter Roberson
Walter Roberson 2019 年 11 月 16 日
編集済み: Walter Roberson 2019 年 11 月 16 日
You should not modify it to assign input64 and mode and key in the code. You should define the function as accepting up to 3 input variables, input64, mode and key and you should pass the desired values into the function.
If you insist on defining the variables inside the function, then comment out the narginchk line and the entire switch block with all cases.
  3 件のコメント
Walter Roberson
Walter Roberson 2019 年 11 月 18 日
If you are using the FEX contribution DES then you have to pass arguments to it when you run it.
k = keygen;
msg = 'To be, or not to be!'
emsg = DES(msg, k, 'ENC');
dmsg = DES(emsg, k, 'DEC')
sadiqa ilyas
sadiqa ilyas 2019 年 11 月 19 日
Thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeString Parsing についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by