Simple Message Encryption with Matricies
조회 수: 2 (최근 30일)
이전 댓글 표시
Trying to demonstrate message encryption with multiplicaiton o fmatricies and inverse matricies.
Code is as follows:
clear; clc;
M = [72 97 112; 112 121 32; 84 104 97; 110 107 115; 103 105 118]
N = [1 5 8 ; 4 4 2 ; 7 7 7];
NI = inv(N);
E = M*N;
F = E * NI;
FE = char(F(1,:))
The first three letters (FE) keep coming out as "Hao" instead of "Hap". Anyone know what is going on here? I even converted these values from the character string to doubles first so I know the ASCII string is accurate to the message. Thanks for any help!
댓글 수: 0
채택된 답변
Walter Roberson
2019년 11월 18일
>> mod(F(1,:),1)
ans =
4.2632564145606e-14 0 0.999999999999943
char() truncates rather than rounding so 111.999999999999943 would display as 112 in the format you are using, but it is not quite 112 and char() would convert to position 111.
댓글 수: 3
추가 답변 (1개)
KALYAN ACHARJYA
2019년 11월 18일
Please di read here char
As per the char character array
>> ascii = char(reshape(32:127,32,3)')
ascii =
3×32 char array
' !"#$%&'()*+,-./0123456789:;<=>?'
'@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_'
'`abcdefghijklmnopqrstuvwxyz{|}~'
In the code
>> F(1,:)
ans =
72 97 112
Hence
>> FE=char(ans)
FE =
'Hao'
where
>> char(72)
ans =
'H'
>> char(97)
ans =
'a'
>> char(112)
ans =
'p'
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Syntax for States and Transitions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!