Alhazred's Profile User Rating: -----

Reputation: 9 Worker
Group:
Active Members
Active Posts:
181 (0.07 per day)
Joined:
25-July 07
Profile Views:
5,950
Last Active:
User is offline Oct 20 2014 11:55 AM
Currently:
Offline

Previous Fields

Country:
IT
OS Preference:
Windows
Favorite Browser:
FireFox
Favorite Processor:
AMD
Favorite Gaming Platform:
PC
Your Car:
Ford
Dream Kudos:
0

Latest Visitors

Icon   Alhazred has not set their status

Posts I've Made

  1. In Topic: openssl: problem with the key to encrypt and decrypt

    Posted 20 Oct 2014

    Yes, you are probably right, I'll use an hash for the comparison.
    Thank you.
  2. In Topic: openssl: problem with the key to encrypt and decrypt

    Posted 20 Oct 2014

    Each of the strings which I will have to encrypt are unique, I will never encrypt twice the same string, all the encrypted strings into my db will be different, so no use to perform an occurrency statistic to guess the original text.
    This is not the case, but to make it simple, think to encode emails, emails addresses are unique and if there are not 2 entries for the same email, there will not be twice the same encrypted string.

    I need to use RSA encription because that is required by the project on which I'm working, I have to check if a crypted string is already present on the database, but the private key to decode the data is not accessible by the application, that's why I need to avoid a random seed during the encryption.
  3. In Topic: openssl: problem with the key to encrypt and decrypt

    Posted 20 Oct 2014

    I've got another question about the encryption, using OPENSSL_PKCS1_PADDING the encryption works and the cypted string changes everytime.
    Now I need to have the same string for a given text.
    I tried to use OPENSSL_NO_PADDING, but with this constant the encryption fails.

    What is the problem?

    This is the test code in use
    $key = "-----BEGIN PUBLIC KEY-----
    MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0
    FPqri0cb2JZfXJ/DgYSF6vUpwmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/
    3j+skZ6UtW+5u09lHNsj6tQ51s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQAB
    -----END PUBLIC KEY-----";
    
    $data = "String to encrypt";
    
    $res = openssl_public_encrypt($data, $encrypted_data, $key, OPENSSL_NO_PADDING);
    
    if ( ! $res )
    {
        // I get this message if I use OPENSSL_NO_PADDING to encrypt
        echo "Encryption failed!";
    }
    else
    {
        // I get this message if I use OPENSSL_PKCS1_PADDING to encrypt
        echo base64_encode($encrypted_data);
    }
    
    
  4. In Topic: openssl: problem with the key to encrypt and decrypt

    Posted 13 Oct 2014

    I've found the problem, for some reason the keys pair generated by the command
    ssh-keygen -t rsa
    were not good to be used with my code.
    I got a new pair by an online generator and now the code works.

    I also kept the file_get_contents() function to read the files containing the keys.
  5. In Topic: openssl: problem with the key to encrypt and decrypt

    Posted 13 Oct 2014

    Of course I'm using it just for test, that's not the pair I will really use.

    I've tried with file_get_contents(), but the problem persists.
    I think I have to properly set the keys on my PC, but I've not understood how to do that.

My Information

Member Title:
D.I.C Head
Age:
38 years old
Birthday:
September 30, 1976
Gender:
Location:
Italy
Programming Languages:
C, Java, php

Contact Information

E-mail:
Private
Website URL:
Website URL  http://

Friends

Alhazred hasn't added any friends yet.

Comments

Page 1 of 1
  1. Photo

    jesicalbaby Icon

    16 Sep 2013 - 14:34
    Hello
    My name is Miss jesical,
    i saw your profile today
    and,i fill more interest to contact you ,
    i will like you to please send me
    an email via (jesicalduncan22@yahoo.com)
    for me to send you my picture
    jesicalduncan22@yahoo.com
Page 1 of 1