/// <summary> /// Encrypt the message with use of Public Key /// </summary> /// <param name="message">Message to encrypt</param> /// <param name="publicKey">Public Key</param> /// <returns></returns> public static async Task <(bool, string)> EncryptMessage(string message, PubKey publicKey) { if (string.IsNullOrEmpty(message) || publicKey == null) { return(false, "Input parameters cannot be empty or null."); } try { var cmsg = publicKey.Encrypt(message); return(true, cmsg); } catch { return(false, "Wrong input. Cannot encrypt the message."); } }
/// <summary> /// Encrypt the message with use of Public Key /// </summary> /// <param name="message">Message to encrypt</param> /// <param name="publicKey">Public Key</param> /// <returns></returns> public static async Task <(bool, string)> EncryptMessage(string message, string publicKey) { if (string.IsNullOrEmpty(message) || string.IsNullOrEmpty(publicKey)) { return(false, "Input parameters cannot be empty or null."); } try { PubKey k = new PubKey(publicKey); var cmsg = k.Encrypt(message); return(true, cmsg); } catch (Exception ex) { return(false, "Wrong input. Cannot encrypt the message."); } }