Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Sichere ProgrammierungLarge AI Labs Face Regulatory Capture Allegations(21.09.2026 um 05:18 Uhr)
Sichere ProgrammierungWhat people are building with Jev: a look through nine awesome lists(21.09.2026 um 05:44 Uhr)
IT Security Toolsnetwatch v0.32.3(21.09.2026 um 04:36 Uhr)
Sichere ProgrammierungLarge AI Labs Face Regulatory Capture Allegations(21.09.2026 um 05:18 Uhr)
Sichere ProgrammierungWhat people are building with Jev: a look through nine awesome lists(21.09.2026 um 05:44 Uhr)
IT Security Toolsnetwatch v0.32.3(21.09.2026 um 04:36 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Secure transfer

Reagiere als Erste:r — dein Feedback zählt!

Usually it's hard to write a secure code without mechanisms (e.g. AES-256, Rijndael-256). But we can provide secure transfer of data, leaning on algorithm Diffie-Hellman.
Consept on Diffie-Hellman key exchange:

  1. 2 people wants to communicate using strong security. They have closed key, like word ("fish") or letter ("D"). But need to turn it into public key
  2. In common space they decide to choose certain Mathematical (cryptographic) function: a^b mod n
  3. a meens "D", b and n choosing together, general for 2 people
  4. The last one: fuction result is sent to each other and decrypt by reverse Mathematical function.

Let's see the code!

void crypt(int p, int g, int x, string in, vector <pair<int, int> > &mas) {

            int y = power(g, x, p);

            cout << "Открытый ключ (p,g,y) = " << "(" << p << "," << g << "," << y << ")" << endl;
            cout << "Закрытый ключ x = " << x << endl;

            cout << "\nШифруемый текст:" << endl;

            for (unsigned int i = 0; i < size(in); i++) {
                int m = in[i] + 256;
                if (m > 0) {
                    cout << (char)m;

                    int k = rand() % (p - 2) + 1; // 1 < k < (p-1) 
                    int a = power(g, k, p);
                    int b = mul(power(y, k, p), m, p);
                    mas.push_back(make_pair(a, b));
                }
            }

            cout << endl;
        }

You see p, g, y = a, b, n. And x - result of encrypted function (public key). m - internal value for counting each bits of message (m), which is encrypted with a private key.
crypt(593, 123, x, message_in, cypher); - example of call our function.

And being on the recipient's spot, we need to decrypt this message (m).

void decrypt(int p, int x, vector <pair<int, int> > mas, string &out) {

            cout << "\nДешифрованый текст:" << endl;

            unsigned int i = 0;
            while (i < mas.size()) {
                int a = 0;
                int b = 0;
                a = mas[i].first;
                b = mas[i].second;

                if (a != 0 && b != 0) {
                    cout << a << " " << b << endl;

                    int deM = mul(b, power(a, p - 1 - x, p), p);// m=b*(a^x)^(-1)mod p =b*a^(p-1-x)mod p
                    char m = static_cast<char>(deM);
                    out.push_back(m);

                    i++;
                }
            }

            cout << endl;
        }

decrypt(593, x, cypher, messagge_out); - similarly for calling decrypt function. Here we already don't need all parametres - only closed key.

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Secure transfer

Thematisch verwandte Begriffe: Secure, transfer · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-94104 | NivoCart through 2.4.0 contains an arbitrary file upload vulnerability i…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick