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 8076585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:17:26+00:00 2026-06-05T15:17:26+00:00

Good day. I need to teach Windows CryptoAPI to encrypt the message with private

  • 0

Good day.

I need to teach Windows CryptoAPI to encrypt the message with private (not public) part of the key, and decrypt with public. This is necessary to give users information, that they can read, but can’t change.

How it works now:

I get the context

CryptAcquireContext(@Prov, PAnsiChar(containerName), nil, PROV_RSA_FULL, 0)

generate a key pair

CryptGenKey(Prov, CALG_RSA_KEYX, CRYPT_EXPORTABLE, @key)

Encrypt (and the problem is here. “key” – a keypair, and the function uses its public part);

CryptEncrypt(key, 0, true, 0, @res[1], @strLen, buffSize)

Decrypt (the same problem here, it uses the private part of the key)

CryptDecrypt(key, 0, true, 0, @res[1], @buffSize)

Thank you for your attention / help.

Update

Yes, I could use a digital signature and other metods…

The problem is that I need to encrypt one database field and make sure that no one but me can change it. It will be possible to read this field only with the help of my program (till someone decompiles it and get public key). This could be done with symmetrical key and digital signatures, but then i will need to create another field and store another key and so on…

I do hope that we can somehow teach WIN API to do as I want. I know that i can do so with RSA, and I hope that somehow WinAPI supports this feature.

  • 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-05T15:17:27+00:00Added an answer on June 5, 2026 at 3:17 pm

    Encrypting data with the private key and decrypting it with the public key isn’t supported because anyone with the “published” public key could decrypt it. What’s the value in encrypting it then?

    If you want to verify that data hasn’t been changed, you will want to sign the data instead. Signing encrypts a hash of the data with the private key. Look at the signing functions.

    You may be able to trick out the signing functions to do what you want. I’ve done this with other implementations, but I haven’t tried with the Microsoft CryptoAPI.

    Also, note that with RSA encryption, the plain text message cannot be longer than the key. So, if you are using a 2048 bit key, you can only encrypt a message body of up to 256 bytes (minus a few for overhead).

    Consider using asymmetric encryption just to pass a symmetric key, and use the symmetric key to encrypt and decrypt any size data.

    Update

    You may be able to use the CryptSignHash() function for this. Normally, this is used to “sign” a hash, but you can put any data you want into the hash:

    Set the hash value in the hash object by using the HP_HASHVAL value of
    the dwParam parameter in CryptSetHashParam.

    You might be limited to so many bytes if the input is expected to be a SHA1 hash value.

    Alternatively, you may wish to consider using OpenSSL. If I recall correctly, it’s pretty straight forward to use its RSA signing functions to encrypt with the private key.

    Also, I accomplished the same thing using the old (freeware) version of SecureBlackbox. You may be able to find the old free version, but it’s not Unicode friendly, so you’ll have some conversion to do if you’re using a new Delphi. I’ve done this in the past also, so it’s not too difficult.

    You may also consider trying out the current SecureBlackbox and purchase it if it works for you.

    Otherwise, as you stated, sign it to detect tampering, and encrypt it with a symmetric key that only the program knows in order to obfuscate it.

    If they crack your code, anything’s fair game anyway.

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

Sidebar

Related Questions

Good day everyone I need to execute command on linux machine this command is
Good day, I need to extract portion of string which can looks like this:
Good day! I need to run ASP.NET MVC application not in the root of
Good day, I'm not sure if this is possible but I want to merge
Good day everyone. This problem was part of another one which it as been
Good day, I have like 15 images I need to be buttons. I have
Good day, I have a requirement which i need to include a layout (actually
Good Day, Can someone confirm what was said at the bottom of this post
Good day, all. I know that this is a pretty basic question in terms
Good day to all. I need to create a graphical countdown in js. The

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.