Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

verschlüsselung in c++

Empfohlene Antworten

Veröffentlicht

Hallo,

ich versuche gerade ein kleines programm zu schreiben in dem ich einen string und später eine datei verschlüsseln kann, und noch später würd ich gern den sha hash mit einbauen wollen, jedoch weiß ich nicht wie ich anfangen bzw welche komponente ich dafür am betsen benutzen könnte. ich habs mit crptopp versucht aber jedoch steige ich da einfach nicht durch die befehle durch :( könntet Ihr mir evtl weiterhelfen ?? danke schon einmal

  • 2 Wochen später...
Die Hilfedatei, die du hier finden kannst, bietet einen guten Einstieg in Crypto++.

hallo danke für deinen link aber irgendwie will einfach der groschen nicht fallen und möchte dich daher nocheinmal um hilfe bitten ich hab ein ziemlich kurzes beispiel gefunden mit folgendem Code:


// aestest1.cpp
#include "StdAfx.h"

// Runtime Includes
#include <iostream>
#include <iomanip>

// Crypto++ Includes
#include "cryptlib.h"
#include "aes.h" // AES
#include "modes.h" // CBC_Mode< >
#include "filters.h" // StringSource

int main(int argc, char* argv[]) {

// Key and IV setup
byte key[ CryptoPP::AES::DEFAULT_KEYLENGTH ],
iv[ CryptoPP::AES::BLOCKSIZE ];

::memset( key, 0x01, CryptoPP::AES::DEFAULT_KEYLENGTH );
::memset( iv, 0x01, CryptoPP::AES::BLOCKSIZE );

// Message M
std::string PlainText = "Hello AES World";

// Debug
std::cout << "Plain Text:" << std::endl;
std::cout << " '" << PlainText << "'" << std::endl;
std::cout << std::endl;
std::cout << "key: ";
std::cout << key <<std::endl;

// Cipher Text Sink
std::string CipherText;

// Encryption
CryptoPP::CBC_Mode<CryptoPP::AES>::Encryption
Encryptor( key, sizeof(key), iv );

CryptoPP::StringSource( PlainText, true,
new CryptoPP::StreamTransformationFilter( Encryptor,
new CryptoPP::StringSink( CipherText )
) // StreamTransformationFilter
); // StringSource

// Debug
std::cout << "Cipher Text (" << CipherText.size() <<") bytes:" << std::endl;
for(unsigned int i = 0; i < CipherText.size(); i++ )
{
if( 0 != i && 10 == i ) { std::cout << std::endl; }
std::cout << std::hex << "0x";
std::cout << ( static_cast<unsigned>( 0xFF & CipherText[ i ] ) ) << " ";
}
std::cout << std::endl << std::endl;

///////////////////////////////////////
// DMZ //
///////////////////////////////////////

// Recovered Text Sink
std::string RecoveredText;

// Decryption
CryptoPP::CBC_Mode<CryptoPP::AES>::Decryption
Decryptor( key, sizeof(key), iv );

CryptoPP::StringSource( CipherText, true,
new CryptoPP::StreamTransformationFilter( Decryptor,
new CryptoPP::StringSink( RecoveredText )
) // StreamTransformationFilter
); // StringSink

// Debug
std::cout << "Recovered Text:" << std::endl;
std::cout << " '" << RecoveredText << "'" << std::endl;
std::cout << std::endl;

return 0;
}
[/PHP]

nun das ausführen klappt wunderbar nun frage ich mich allerdings wo zum geier wird da der Wert zum verschlüsseln festgelegt (quasi das PW).

wie gesagt irgendwie klemmt es da bei mir mit crypto++ im vorraus schon einmal vielen dank



// Key and IV setup
byte key[ CryptoPP::AES::DEFAULT_KEYLENGTH ],
iv[ CryptoPP::AES::BLOCKSIZE ];

::memset( key, 0x01, CryptoPP::AES::DEFAULT_KEYLENGTH );
::memset( iv, 0x01, CryptoPP::AES::BLOCKSIZE );


[/PHP]

ok das bedeutet also das mit byte der kye und iv nach vorgabe von crypto++ initialisiert wird und memset weißt dann das byte "0x01" der gesamten länge zu. aber muß denn das unbedingt ein byte sein oder kann ich auch einen string hinzufügen ?? und wenn ja könntest du mir kurz weiterhelfen wie das dann aussehen müßte ?

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.