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

  • SEARCH
  • Home
  • 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 8736283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:16:15+00:00 2026-06-13T10:16:15+00:00

Ok so i am VERY new to cryptography I want to encrypt a string

  • 0

Ok so i am VERY new to cryptography

I want to encrypt a string using RSA. i have found many examples but most of them generate their own public/private keys or they use some other key format like pem/crt etc

I have my own public and private key file in the format of .key

Public key -> http://pastebin.com/hPT9LRCT 
Private key-> http://pastebin.com/UYgJp8K7

How do i encrypt a string (“hello world”) using my public key in php?

Could you show me an example or point me in the right direction?

thanks,
Vidhu

  • 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-13T10:16:17+00:00Added an answer on June 13, 2026 at 10:16 am

    Try this (uses phpseclib, a pure PHP RSA implementation):

    <?php
    include('Crypt/RSA.php');
    
    $rsa = new Crypt_RSA();
    $rsa->loadKey('MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArd+uKDi7g6cpmbotPre9KpFK4U1rM/FlEtHszIrMBmArLID4/uImes2L6K5sbKHbo3sIVdzFgrtB/ZdHTN11bM26OLpovCMs/HF3tqz93RMobdNv63IyOau4YgKZa+U2sW+1fGT1HtBesqGjlVlLZNJVR9ZETj4fuLKjNzOgegdbYFV9jIyP6JDi/9c6oyFRUI1anSWZcDFL+74Y4h4okAcbDgooczxBf3QlIJQdFVs9GOPCoIwmZ29c4VmBvESlRnjtXho/6sNQXlnLsG4v4GCzL7P1YOOf9FqV8XZuXJrEsTVJjDdYJdia6F3G/GRe+lRhReM42qlHqLKZpzjSFwIDAQAB'); // public key
    
    $plaintext = 'hello world';
    
    $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
    $ciphertext = $rsa->encrypt($plaintext);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im very new in C++ I have found this post http://msdn.microsoft.com/en-us/magazine/cc163486.aspx and trying to
I have a two very simple methods to encrypt/decrypt a byte[] using the AesCryptoServiceProvider.
Im very new to C programing, but have limited experience with Python, Java, and
Very new SQL Server, am using SQL server 2008. I have two tables, Table
Very new to AJAX, but have learned a bit from online tutorials. If I
Very new to Rails, have managed a few simple projects, but now stepping into
I have a string that's encrypted using some crypto classes in Java (RSA/ECB/PKCS1Padding) and
Very new to python and can't understand why this isn't working. I have a
Very new to C++ and Cocos2d-x but I was just toying around with CCArray
Very new to FluentNHibernate, but I'm also excited about the area. I've recently started

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.