📄 elgamal.m
字号:
%% ElGamal PKC%% Functions:%% pub_key_gen% encrypt(p, Alpha, Betaa, m)% decrypt(y1, y2)%%%% Use:% % pub_key_gen - Generates the public key for the receiver. This function% requires no arguments and simply chooses a large prime p% of a maximum size of 128 bits. The receiver is to type % this at the beginning to compute his or her publick key.%% ELGencrypt()- Encrypts the sender's message. This function takes 4 inputs.% These inputs are the published values of p, Alpha, and Betaa.% The 4th input is the message that the sender plans to send.%% This function is called from within the encrypt.m script as% the sender does not need to call it explicitly but only needs% to type encrypt followed by the message after being prompted.%% The message cannot contain any spaces and if it is too long% will generate an error. If a long message needs to be sent% the sender will need to break it up into manageable portions% and send each portion individually by calling the encrypt % function for each piece of the message.% % The sender must allow the receiver to decrypt each part of % the message before sending the next part.%% The size of the message depends on the chosen p.%% decrypt() - Decrypts the message encrypted by the sender. The receiver% supplies this function with the values produced by encrypt().% These values are y1 and y2 and are the only arguments needed% for the function to decrypt the ciphertext. %% Note: The user simply calls these functions and uses the variables % within the calls (i.e p, Alpha, Betaa, y1, y1) instead of % copying the values of those into the arguments. % % Secret key - It is important to note that the secret key for this PKC is % already set to a predetermined value. For this to change you% must manually edit the code of pub_key_gen. The private key% is stored in variable 'a'. % greetingdisp(' ')disp(' ')answer = input('Would you like to continue and call the public key generator \nfunction? y/n\n\n','s')if (answer == 'y') pub_key_genelse disp('If you want to run this program again simply type "elgamal" at the') disp('MATLAB prompt. To avoid the start screen you may directly type') disp('"pub_key_gen" to generate your public key.')end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -