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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:48:52+00:00 2026-05-31T14:48:52+00:00

I made a user table in my DB with different columns for holding users’

  • 0

I made a user table in my DB with different columns for holding users’ info. Also I have added two columns public_key and private_key.
When a user registers, his info will be inserted to the table. plus I am using:

// Create the keypair
$res=openssl_pkey_new();

// Get private key
openssl_pkey_export($res, $privatekey);

// Get public key
$publickey=openssl_pkey_get_details($res);
$publickey=$publickey["key"];

to create a random key pair and give it to user so that every user has a key pair.
I want my users to have digital-signature ability, so when they upload a file they sign it.

I decided to sign a sample file(msg.txt) first to see if I can and then proceed. It looks straight forward:

openssl_pkcs7_sign("msg.txt", "signed.txt", "signing_cert.pem",
array("private_key.pem", "mypassphrase"),
array()
);

The problem is: what are signing_cert.pem and private_key.pem ? I pasted my generated public key in signing_cert.pem and the private one in private_key.pem, but I see this error:

Warning: openssl_pkcs7_sign() [function.openssl-pkcs7-sign]: error getting 
private key in /home/ofathian/public_html/msc/ebook/mine/assymetric-test.php 
on line 40

Any opinion is appreciated.

  • 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-05-31T14:48:53+00:00Added an answer on May 31, 2026 at 2:48 pm

    I came to conclusion of why not make my own digital signing function.

    digital signing algorithm works like this:
    first the plain text is hashed then it is encypted by user’s private key, then the result
    is concatenated with the plain text.

    pseudo code:

    return [input + encrypt(md5(input),private_key)]
    

    For verifying: Input is splitted to plain text and signature. then signature is decrypted
    using public key. Then the result is compared to the hash of the plain text and if they
    are equal it means the signature is verified.

    pseudo code:

    explode(input) --> plain_text , signature
    if( decrypt(signature,public_key) == md5(plain_text) ) then signature is trusted
    

    Now the real PHP code which I have tested and currently using:

    function sign($cleartext,$private_key)
    {
        $msg_hash = md5($cleartext);
        openssl_private_encrypt($msg_hash, $sig, $private_key);
        $signed_data = $cleartext . "----SIGNATURE:----" . $sig;
        return mysql_real_escape_string($signed_data);
    }
    
    function verify($my_signed_data,$public_key)
    {
        list($plain_data,$old_sig) = explode("----SIGNATURE:----", $my_signed_data);
        openssl_public_decrypt($old_sig, $decrypted_sig, $public_key);
        $data_hash = md5($plain_data);
        if($decrypted_sig == $data_hash && strlen($data_hash)>0)
            return $plain_data;
        else
            return "ERROR -- untrusted signature";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table called users and each user can belong to one group,
I have made a user control in asp.net c#. Becuase of some data I
I have an application that needs to determine whether a user has made a
I made this function to verify a user's twitter credentials. Its running on two
I have made an application that gives the user the option to open up
For several applications I made for my current client I have shared user accounts.
I have made a little app for signing up for an event. User input
I have a system where, essentially, users are able to put in 3 different
I have two entities, User and UserPermission. The User entity contains all your normal
I have a users table that has the following fields: userid, phone, and address

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.