PHP, MySQL, ve kullanıcı verileri için AES şifreleme / şifre çözme

0 Cevap php

Ben AES şifreleme için yeni fakat bir çözüm oluşturmak için çalışıyor:

  • Tüketici verileri kabul
  • Encrypts that data using AES and a "public" key
  • MySQL veritabanında verileri saklamak
  • Have the ability to pull and decrypt the data ONLY with a private key (stored on my personal machine, not the server itself).

Ben bu overkill olabilir farkında ama benim tüketici veri aşırı koruma olmak istiyorum.

Unutulmaması gereken bir kaç şey:

  1. This is not credit card information so please don't write telling me about PCI-DSS, it is other form of personal information all under 500 characters in length for each field.
  2. I may store pieces of the consumer information and others in a second database tied together by a unique member ID for additional security.
  3. Incoming MySQL calls can only be made to my server directly from my static IP.
  4. SSH root is disabled, ports changed, and so on so I feel my server is in faily good shape to prevent any "basic" misuse.

Ben online ve SO makaleler için baktım ama tamamen sunucusu kapalı özel anahtarı tutmak açısından çok bulamadık. Ben sunucusunun kendisinde tutmak gerek bile - ileriye taşımak için nasıl bir düşünce veya önerileri takdir edilmektedir.

EDIT - CLARIFICATION

Sadece daha temiz olması için, ben başarmak için çalışıyorum gol (çok temel formda) şudur:

  • Customer enters his/her phone number online.

  • The phone number entered is encrypted online using key A and stored within the mysql db

  • The customer will never be able to see the full phone again at this point, but can certainly update it (going through key A process a nth time)

  • Bir sistem yöneticisi olarak, ben sadece birini indirmek ve benim yerel makinede verileri şifresini verilere erişmek için (o ya ben ilk o zaman ihtiyacım verilerin şifresini çözmek için kullanılan geçici dosya upload gerekir) mümkün duyuyorum.

EDIT 2 - I'm a an idiot

Ben aşağıda Andrew Cooper yanıtı kullanıyorum ama ben oluşturulan. Pem dosyasının içeriğini okumak için benim komut alma konusunda sorun yaşıyorum. Aşağıdaki kodu dayanmaktadır -. Nasıl benim sunucusunda belirli pem dosyaya karşılık $ kamu anahtarını almak istiyorsunuz?

<?php

if (isset($_SERVER['HTTPS']) )
{
    echo "SECURE: This page is being accessed through a secure connection.<br><br>";
}
else
{
    echo "UNSECURE: This page is being access through an unsecure connection.<br><br>";
}


// 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"];

echo "Private Key:<BR>$privatekey<br><br>Public Key:<BR>$publickey<BR><BR>";

$cleartext = '1234 5678 9012 3456';

echo "Clear text:<br>$cleartext<BR><BR>";

openssl_public_encrypt($cleartext, $crypttext, $publickey);

echo "Crypt text:<br>$crypttext<BR><BR>";

openssl_private_decrypt($crypttext, $decrypted, $privatekey);

echo "Decrypted text:<BR>$decrypted<br><br>";
?>

EDIT 3 - maybe not 'idiot' but semicolons hate me

Ben yanlış bir noktalı virgül vardı. I işlevini kullanıyorum:? Izle () ama pem dosyası için veri okuma daha tercih edilen bir yöntem yoktur.?

0 Cevap