How can I use the function affinecrypt in Matlab
显示 更早的评论
Hi I want to use the function affinecrypt and I have a code for it that I got from http://www.math.umd.edu/~lcw/MatlabCode/ But when I try to use it in Matlab it dosnt work and I get the answer Error: Function definitions are not permitted in this context. This is the code I am trying to use:
function y = affinecrypt(x,a,b); % This function performs the affine encryption function % y = a x + b mod 26 % where (a,26) = 1 % The result is kept in numerical representation
xnum=text2int(x); ynum = mod( a*xnum + b, 26); y=int2text(ynum);
1 个评论
Jan
2018-3-21
Wow, this is the 5'th time in the last 30 minutes, where I ask a user to format the code such, that it is readable. Please read http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup.
回答(2 个)
Jan
2018-3-21
You did not tell us, what you try to do with this code snippet. When do you get the error message? Do you try to insert this piece of code in the command window? This cannot work. Safe this file to a folder, which is included in your path (see: doc addpath) and call it from the command window or any other function with the input arguments:
y = affinecrypt(23, 4, 117) % Or what ever your parameters are
bo nilsson
2018-3-21
0 个投票
1 个评论
"It doesn't work" is not useful to explain a problem. Please do not let us guess the details. Which error message do you get?
Please post comments in the section for comments, and not as an answer. This message belongs to the original question, so better insert it there by editing it.
And, please, bo nilsson, format your code properly. I do not understand, why to ignore that I have asked for it. But it should be in your interest to offer a code which can be read as easy as possible.
类别
在 帮助中心 和 File Exchange 中查找有关 Get Started with MATLAB 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!