Ejemplo n.º 1
0
 /// <summary>
 /// Encrypts a string with the server's public key and convert it to base64.
 /// </summary>
 /// <param name="s">The string to be encrypted.</param>
 /// <returns>The encrypted string in base64 format.</returns>
 private String PpEncryptAndBase64(String s)
 {
     Contract.Requires(!ReferenceEquals(s, null));
     RSACrypto rsa = new RSACrypto();
     rsa.ImportCspBlob(_publicKey);
     byte[] sEncrypted = rsa.Encrypt(_utf8.GetBytes(s));
     return Convert.ToBase64String(sEncrypted);
 }