⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 decrypt.m

📁 elgamal elgrithm by matlab
💻 M
字号:
function message = decrypt(y1, y2)% Uses y1 and y2 to decrypt message% Get y1 and y2 valuemaple('y1:=',y1);maple('y2:=',y2);% Calculate the numberic plain text using y1 and y2 from the sendermaple('num_plaintext :=', '(((y1&^a)&^(-1))*y2) mod p');num_plaintext = maple('num_plaintext');% Convert numberic plain text to charactersnum_plaintext_length = numel(num_plaintext);odd = rem(num_plaintext_length,2);% If the length of numberic plain text is even number% This means the numberic value of the first character is equal or greater than 10% We can convert every 2 consecutive numbers to one characterif odd==0,;z=1;plaintext = '';for n=1:num_plaintext_length/2,;    q = ((num_plaintext(z)-48)*10)+(num_plaintext(z+1)-48);    plaintext = strcat(plaintext,char(q+'a'-1));    z=z+2;end;  message = plaintextend;% If the length of numberic plain text is odd number% This means the numberic value of the first character is less the than 10% We convert first single number to the first character% For the rest of them, we convert every 2 consecutive numbers to one characterif odd==1,m = floor(num_plaintext_length/2) + 1;q = num_plaintext(1)-48;plaintext = char(q+'a'-1);z=2;for n=2:m,    q = ((num_plaintext(z)-48)*10)+(num_plaintext(z+1)-48);    plaintext = strcat(plaintext,char(q+'a'-1));    z=z+2;end;  message = plaintextend;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -