Показать сообщение отдельно
Старый 10.02.2023, 16:56   #6  
imir is offline
imir
Участник
 
159 / 161 (6) ++++++
Регистрация: 28.05.2010
Если есть пара открытый-закрытый ключ, то можно попользоваться System.Security.Cryptography; наверное
Пример на C# нарыт в интернетах.

Вопрос - где надежно хранить закрытый ключ для дешифрования, в ресурс зашивать или в папке, в кторую имеет доступ только учетка AOS - ну такие себе варианты.

X++:
using System;
using System.Security.Cryptography;
using System.Text;

namespace RSAEncryptionExample
{
    class Program
    {
        static void Main(string[] args)
        {
            string originalText = "Text to be encrypted";
            byte[] encryptedText;

            // Get the public key from a file
            string publicKey = File.ReadAllText("publickey.xml");

            // Create an instance of the RSA algorithm with the public key
            RSA rsa = RSA.Create();
            rsa.FromXmlString(publicKey);

            // Encrypt the original text using the RSA algorithm
            encryptedText = rsa.Encrypt(Encoding.UTF8.GetBytes(originalText), RSAEncryptionPadding.OaepSHA1);

            Console.WriteLine("Encrypted Text: " + Convert.ToBase64String(encryptedText));
        }
    }
}