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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:18:19+00:00 2026-06-13T00:18:19+00:00

I don’t know what I am doing wrong or maybe I just haven’t thought

  • 0

I don’t know what I am doing wrong or maybe I just haven’t thought it through. I want to sign some text and verify it immediately after that. I am using the RSA signature algorithm from phpseclib. It works but now I want to test if the verfication fails if I change the text I signed before. It shouldn’t verify the text because it differs from the original one. So I wrote some code and tested it 10 times. 4 times the algorithm verifies the signature and 6 times it fails. Isn’t that weird?
Here is my code. Basically I created a public/private key pair and just used the functions from phpseclib.

<?php
include('Crypt/RSA.php');

$private_key = <<<EOD
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQCmGJj20JA2taFPLjnxSuD8sUFwWnVQU7iECgdmmmKy5IDGx4Hv
P4ZxHOVVlqxVnz7lbvxhJahWVmBrHV9vj6w+9khaxo6j4Q7dZvDHt9VhgFyODy8M
V97X8Le2WZuRzINhNziYptGIX9hPbSxl5IEFY7Mcev3NF0IswVtn8+Oy+QIDAQAB
AoGASzST/h1NTxhKY7nAjpqi6Iex45dxyt89irunwjNhQTLphBfNo3CWBR1aUbiZ
a2NhbS0lpS8R25XcrmNsVO0uxdCpVnHwzuQLI61kv9Bu8i1/TpCG8yGGSU4+gi7x
12y943RkNYMqg8X0esupMTx4xhaHlTBt/dhAe7yB9nK1haECQQDQ/P2XcCXkO+lH
cImjhx9BjL8TdXUeZmbsMEmHJM7pqtYEybdjf2zTBqOOmehkczCTeWQD074xFqrW
K707lRLlAkEAy3WTTKFSwjGy2JC+iym+Yp5biYGwsAL3zXj6y0k1BHIWOoc59GrO
tpbUBMXmX7g6g/KZ8VkboW0xtnoyVPU6hQJBALYDgQGBxR6QJ03274kix9AZOtlB
tS0y1nTiYUd4gVT1Wsx0umnHswnfgFdUKBhEUow+byL+KWkrasJ4+aiI3xkCQEPp
K9BxLIF7OzoEHkWvGkgqmV0td79YTkQ8NGH0PokMV5UTm+mUWQkjEQPC1qFuicGP
EYk4d/uKygQhh3lKHU0CQHUmD9ch6POTOnBIt67EhQ8Dt/nIQqnjYOWi+x5xLT0T
zORMLod6pO16USOk1nNk6FtCxlsbQTsaaEZ6xw3WsMQ=
-----END RSA PRIVATE KEY-----
EOD;
$public_key = <<<EOD
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCmGJj20JA2taFPLjnxSuD8sUFw
WnVQU7iECgdmmmKy5IDGx4HvP4ZxHOVVlqxVnz7lbvxhJahWVmBrHV9vj6w+9kha
xo6j4Q7dZvDHt9VhgFyODy8MV97X8Le2WZuRzINhNziYptGIX9hPbSxl5IEFY7Mc
ev3NF0IswVtn8+Oy+QIDAQAB
-----END PUBLIC KEY-----
EOD;

$rsa = new Crypt_RSA();
$rsa->loadKey($private_key);
$plaintext = 'Beer';
$signature = $rsa->sign($plaintext);
$rsa->loadKey($public_key);
$plaintext = '';
var_dump($rsa->verify($plaintext, $signature)); //should always fail but doesn't
?>
  • 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-13T00:18:20+00:00Added an answer on June 13, 2026 at 12:18 am

    Try the latest Git version. It’s probably this bug:

    https://github.com/phpseclib/phpseclib/commit/ee25c73a448d24f8658e074e90d8811774678d93

    Quoting the log,

    “- Fix signature verification (thanks Richard Odekerken!)”.

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

Sidebar

Related Questions

Don't know if it's I'm doing it wrong or if there's a bug (I
Don't get me wrong, I want them to get saved. But I always thought
don't know what happened in my jcrop selection. I think I pressed some keys
I don't know why, but this code worked for me a month ago... maybe
Don't know what's wrong here, when I run the application it says Specified method
Don't know if I worded the question right, but basically what I want to
Don't exactly know what to search for: If i edit text in vim it
Don't know whether I'm having a "thick day" - but I just wondered what
don't know if the title describes anything about what I'm trying to say but
Don't be scared of the extensive code. The problem is general. I just provided

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.