Home>
Only class or namespace names can be followed by':: ~'

I am studying file encryption/decryption in C ++.
I'm also studying C ++.
I came across the following code, so I'd like to try it, but I get an error.

#include<iostream>
#include 
#include<dh.h>
#include<modes.h>
#include<osrng.h>

// Key data initialization
void InitKey (byte * key, size_t size) {
    for (size_t i = 0;i<size;++ i) {
        key [i] = rand ();
    }
}
// Main function
int main () {
    // Common key/IV
    byte key [CryptoPP :: AES :: DEFAULT_KEYLENGTH];
    byte iv [CryptoPP :: AES :: BLOCKSIZE];
    // Initialize the common key and IV with appropriate values
    InitKey (key, sizeof (key));
    InitKey (iv, sizeof (iv));
    std :: string plainText = "plaintext before encryption";
    std :: cout<<"Plain Text:"<<plainText<<std :: endl;
    // Create an encrypted object
    CryptoPP :: CTR_Mode<cryptoPP :: AES>:: Encryption enc;
    enc.SetKeyWithIV (key, sizeof (key), iv);
    // Create a conversion filter for encryption
    std :: string encText;
    CryptoPP :: StreamTransformationFilter encFilter (enc, new CryptoPP :: StringSink (encText));
    // encryption
    encFilter.Put (reinterpret_cast<const byte *>(plainText.c_str ()), plainText.size ());
    encFilter.MessageEnd ();
    std :: cout<<"Encrypted Text:"<<encText<<std :: endl;

    // Create a decryption object
    CryptoPP :: CTR_Mode<cryptoPP :: AES>:: Decryption dec;
    dec.SetKeyWithIV (key, sizeof (key), iv);
    // Create a conversion filter for decryption
    std :: string decText;
    CryptoPP :: StreamTransformationFilter decFilter (dec, new CryptoPP :: StringSink (decText));
    decFilter.Put (reinterpret_cast<const byte *>(encText.c_str ()), encText.size ());
    decFilter.MessageEnd ();
    std :: cout<<"Decrypted Text:"<<decText<<std :: endl;

    return 0;
}
Where an error occurs
  CryptoPP :: CTR_Mode<cryptoPP :: AES>:: Encryption enc;
    CryptoPP :: CTR_Mode<cryptoPP :: AES>:: Decryption dec;


It says that only class or namespace names can be followed by':: ~'.
How can I fix it?

References

http://ftvoid.com/blog/post/283

  • Answer # 1

    CryptoPP :: CTR_Mode<cryptoPP :: AES>:: Encryption enc;
    CryptoPP :: CTR_Mode<cryptoPP :: AES>:: Decryption dec;


    CryptoPP :: CTR_Mode<CryptoPP :: AES>:: Encryption enc;
    CryptoPP :: CTR_Mode<CryptoPP :: AES>:: Decryption dec;