-2

I want to encrypt and decrypt strings with RC6 but I don't understand how it works with the Crypto++ library, could you give me a snippet ?

Thanks you !

jww
  • 97,681
  • 90
  • 411
  • 885
dirac
  • 1
  • 1
  • 3
    A few problems. This question seems overly broad, lacking in research, and looking for general instruction. I think the question can be improved by adding info such as: what online documentation for the CryptoPP library have you looked at, what code have you written and tried so far & in what way doesn't that work including the errors you're seeing. Also, have you used other crypto libraries before? If so, perhaps contrast that experience against using CryptoPP and explain any expected behavior of CryptoPP you have from the other experience(s). – Louis Langholtz Mar 25 '17 at 16:11
  • Hi, Searched a lot but I can't found an code example, I read the CryptoPP doc but I don't understand how the RC6 encryptuin and decryption of a string work, that's why i'm coming to ask a question to you ! Thanks – dirac Mar 26 '17 at 11:51
  • 2
    RC6 is one of the AES candidates. It is one of many block ciphers offered by the library. Find some Crypto++ code for AES, and then perform a copy/paste of AES → RC6. For that matter, any block cipher should work in this instance, including Camellia and 3DES. We added a page on the wiki at [RC6](https://www.cryptopp.com/wiki/RC6), but its just a copy/paste of Camellia. – jww Mar 26 '17 at 22:24

1 Answers1

2

Here's a snippet of code from the Crypto++ website demonstrating how to use the library to encrypt a string using AES (where as jww had pointed out, "RC6 is one of the AES candidates" and the snippet should be usable as a starting point for RC6 as well):

byte key[AES::DEFAULT_KEYLENGTH], iv[AES::BLOCKSIZE];
string plainText;

// ... populate key, iv, plainText here

string cipher;
StringSink* sink = new StringSink(cipher);
Base64Encoder* base64_enc = new Base64Encoder(sink);
CBC_Mode<AES>::Encryption aes(key, sizeof(key), iv);
StreamTransformationFilter* aes_enc = new StreamTransformationFilter(aes, base64_enc);
StringSource source(plainText, true, aes_enc);

I found this information when internet searching for sample code for the Crypto++ library. Admittedly, it wasn't as straight forward for me to find as I had expected.

The Related sidebar on StackOverflow is pointing out other pages that I believe can also help, like the Q & A for Encrypt/Decrypt byte array Crypto++.

Update: An update just showed up today (March 26, 2017) at the RC6 web page at the Crypto++ wiki site. It's got RC6 specific code there now which looks like exactly what you need.

Community
  • 1
  • 1
Louis Langholtz
  • 2,913
  • 3
  • 17
  • 40
  • That's AES, not RC6. – TheGreatContini Mar 26 '17 at 20:47
  • 2
    @TheGreatContini yes agreed. AES isn't exactly RC6. Someone just today edited the crypto++ wiki website and has added code for RC6 specifically. I updated my answer to point this out now. – Louis Langholtz Mar 27 '17 at 01:08
  • 1
    @LouisLangholtz - We use Stack Overflow (and our mailing list) as a feedback loop. If a user has trouble, one of the first things we do is a quick post-mortem. We figure if one user has the question, then other users will have the question. In this case, one of the contributing factors was a lack of documentation on our part. – jww Mar 28 '17 at 17:34
  • For morbid curiosity, checkout some of the top Git questions. Git takes a different approach. When they have a trend, like 100,000 users having the same trouble time and again, they often do nothing. That's not a good Stack Overflow question; rather, its a Git process failure that goes uncorrected. – jww Mar 28 '17 at 17:37