I am trying to decode an encrypted message
조회 수: 2 (최근 30일)
이전 댓글 표시
Here are the files that I have to use.
% First file
encodedString = 'aasfu aic talputte balde';
encryptionKey = [6,7];
% encryptionKey is an array that stores the m-value used in
% perfectMShuffle() function and the number of shuffles performed.
% write the rest of the code, which has to be done in two parts:
% 1) determine the cycle length of the m-shuffle, i.e. how many shuffles
% (including the first one) are needed to return the string to its original
% order
% 2) complete the shuffle cycle on the encoded string to reveal the secret
% message
% Second file
function outString = perfectMShuffle(inString,m)
% This function shuffles the characters in the inString by picking 1st,
% m+1st, 2m+1st characters till it reaches the end, then picking 2nd, m+2nd
% 2m+2nd etc.
% Examples:
% perfectMShuffle('abcdef',3) -> 'adbecf'
% perfectMShuffle('abcdef',2) -> 'acebdf
So how do I approach this problem?
댓글 수: 2
Jan
2013년 10월 15일
This looks like a homework question. For obvious reasons we will not solve this for you, otherwise you would be forced to cheat, when you submit it.
The standard procedure is that you show us, what you have tried so far and ask a specific question.
답변 (1개)
Walter Roberson
2013년 10월 15일
What happens if you reshape() a vector into an array, transpose(), and reshape the result into a vector?
댓글 수: 3
Walter Roberson
2013년 10월 19일
Encode [1:length(inString)] using your encoding method. Then index the encrypted string by the array that resulted from that encoding.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!