Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7741161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:57:17+00:00 2026-06-01T08:57:17+00:00

Do you know of a tutorial that demonstrates Public Private Key encryption(PPKE) in C++

  • 0

Do you know of a tutorial that demonstrates Public Private Key encryption(PPKE) in C++ or C?

I am trying to learn how it works and eventually use Crypto++ to create my own encryptions using public private keys. Maybe theres a Crypto++ PPKE tutorial?

Maybe someone can explain the relationship(if any) between the public and private keys? Could anyone suggest some very simple public and private key values I could use(like ‘char*32′,’char/32’) to create my simple PPKE program to understand the concept?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:57:18+00:00Added an answer on June 1, 2026 at 8:57 am

    Here’s a toy version of RSA I wrote some time back. The thing that makes it a toy is that it only uses 32-bit numbers. To provide any meaningful level of security, you need to support much larger numbers for the math (typical key ranges are something like 1024-4096 bits or so, though the latter probably doesn’t accomplish much).

    Nonetheless, this does implement the real RSA algorithm. It would take relatively little to plug in a bignum package so this code could work with RSA keys of practical size (though most other implementations are probably faster).

    #include <iostream>
    #include <iterator>
    #include <algorithm>
    #include <vector>
    #include <functional>
    
    const int e_key = 47;
    const int d_key = 15;
    const int n = 391;
    
    struct crypt : std::binary_function<int, int, int> {
        int operator()(int input, int key) const { 
            int result = 1;
            for (int i=0; i<key; i++) {
                result *= input;
                result %= n;
            }
            return result;
        }
    };
    
    int main() {
        std::string msg = "Drink more Ovaltine.";
        std::vector<int> encrypted;
    
        std::transform(msg.begin(), msg.end(),  
            std::back_inserter(encrypted),
            std::bind2nd(crypt(), e_key));
    
        std::transform(encrypted.begin(), encrypted.end(), 
            std::ostream_iterator<char>(std::cout, ""), 
            std::bind2nd(crypt(), d_key));
        std::cout << "\n";
    
        return 0;
    }
    

    Of course, this only covers the encryption and decryption itself — that’s a long ways short of being a complete security system.

    Much like the comments have noted, this is intended purely to support understanding of the algorithm. I’ve never put it to serious use, and probably never will. Although supporting real key sizes would be fairly trivial, it’s open to question whether I’ll ever even do that — if I did, somebody might mistake it for something that should be used on real data, which I don’t really intend.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am starting to learn AspectJ. From reading tutorials, I know that I can
Does anyone know of a tutorial for using TeamCity with github with ssh private
do you know any tutorial or script that shows a picture when mousemove over
Does anyone know of a tutorial, or an app with sample code that shows
Does anyone know of a simple tutorial that provides a step by step guide
I'm looking for a tutorial that shows how to use NUnit's integration with visual
Does anyone know a flash example or fla file or tutorial that is related
Does anyone know any good library/tutorial that can do asynchronous image loading for a
Does anyone know of a good tutorial that shows how to lazy load images
Do you know of any tutorial that can help a beginner like me do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.