Implementing Personal Data Encryption on Your Website

When a database leaks, an attacker gets an SQL dump with thousands of rows — INN, passports, medical records. If data is stored in plaintext, it's a disaster: fines under 152-FZ up to 500,000 rubles, or under GDPR up to 4% of global annual turnover. The cost of a data breach averages $3.86 million g

Development and maintenance of all types of websites:

Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:

Frequently Asked Questions

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1414
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1285
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    980
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1240
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    982
  • image_bitrix-bitrix-24-1c_fixper_448_0.webp
    Website development for FIXPER company
    994

When a database leaks, an attacker gets an SQL dump with thousands of rows — INN, passports, medical records. If data is stored in plaintext, it's a disaster: fines under 152-FZ up to 500,000 rubles, or under GDPR up to 4% of global annual turnover. The cost of a data breach averages $3.86 million globally (IBM Cost of a Data Breach Report 2022). Application-level encryption is the only way to devalue data for an attacker. Even if they get the database, without the keys the ciphertext is useless. We implement encryption in projects with high security requirements: fintech, medtech, gov. In 5 years on the market, we have completed over 30 projects for personal data protection. Our engineers hold CISSP certifications, and we guarantee compliance with 152-FZ and GDPR. We will audit your system in 2-3 days.

Let me give a real-world example from our practice: encryption in a medical CRM with 50,000 patients.

Why Encrypt Data at the Application Level?

Database-level encryption (TDE) does not protect against DBAs or SQL injections. The application itself manages keys: data is encrypted before writing and decrypted only by authorized queries. This provides granular access control and isolates data from the infrastructure.

Data Encryption vs Hashing

Data to Encrypt

  • INN, SNILS, passport series/number
  • Medical data, diagnoses
  • Financial data, card numbers (PCI DSS requires a separate approach)
  • Biometrics

Data to Hash

  • Passwords → bcrypt, Argon2id
  • Secret tokens, API keys

For searching encrypted fields, we use deterministic encryption or tokenization — more on that later.

Choosing an Algorithm: AES-256-GCM vs ChaCha20-Poly1305

Algorithm Type Authentication Speed Hardware Acceleration
AES-256-GCM Symmetric Yes (GCM) High Yes (AES-NI)
ChaCha20-Poly1305 Symmetric Yes (Poly1305) High No (but fast in software)
RSA-OAEP Asymmetric Yes Low Yes (partial)

AES-256-GCM is the standard for encrypting data at rest. With AES-NI, it is 3x faster than ChaCha20-Poly1305. If the server lacks AES-NI support, ChaCha20-Poly1305 is a reliable alternative. RSA-OAEP is used for encrypting keys or when decryption cannot be done on the server. More about AES-GCM.

Based on OWASP and NIST recommendations.

Practical Implementation of Encryption in Laravel

Laravel encryption tools provide transparent data protection. We use custom casts to encrypt sensitive fields automatically.

Example Cast for Encrypting Fields
// app/Casts/EncryptedCast.php class EncryptedCast implements CastsAttributes { public function get($model, string $key, $value, array $attributes): ?string { if (is_null($value)) return null; try { return Crypt::decryptString($value); } catch (DecryptException) { return null; } } public function set($model, string $key, $value, array $attributes): ?string { if (is_null($value)) return null; return Crypt::encryptString($value); } } // In the model class Patient extends Model { protected $casts = [ 'passport_number' => EncryptedCast::class, 'medical_notes' => EncryptedCast::class, 'snils' => EncryptedCast::class, ]; } // Usage — transparent to the code $patient->passport_number = '4510 123456'; // automatically encrypted $decrypted = $patient->passport_number; // automatically decrypted 

Advantages of Envelope Encryption

Storing encryption keys in the database alongside encrypted data is pointless. The best practice is envelope encryption: data is encrypted with a Data Encryption Key (DEK), the DEK is encrypted with a Key Encryption Key (KEK), and the KEK is stored in KMS/Vault. This allows re-encrypting data without access to the KEK and simplifies rotation.

HashiCorp Vault integration:

$vault = new Vault([ 'address' => 'https://vault.internal:8200', 'token' => env('VAULT_TOKEN'), ]); $keyData = $vault->read('secret/data/app-encryption-key'); $encryptionKey = $keyData['data']['key']; 

AWS KMS:

use Aws\Kms\KmsClient; $kms = new KmsClient(['region' => 'eu-west-1']); $result = $kms->encrypt([ 'KeyId' => 'arn:aws:kms:eu-west-1:123456:key/abc-123', 'Plaintext' => $sensitiveData, ]); $encryptedData = base64_encode($result['CiphertextBlob']); 

Searching Over Encrypted Data

Standard AES-GCM produces different ciphertext for the same value. Searching an encrypted field is impossible. Solutions:

Option 1: Hash for search + encryption for storage:

class PersonalDataRepository { public function findByPassport(string $passport): ?Patient { $hash = hash_hmac('sha256', $passport, config('app.search_key')); return Patient::where('passport_hash', $hash)->first(); } public function store(string $passport): void { Patient::create([ 'passport_data' => Crypt::encryptString($passport), 'passport_hash' => hash_hmac('sha256', $passport, config('app.search_key')), ]); } } 

Option 2: PostgreSQL pgcrypto:

INSERT INTO patients (passport) VALUES (pgp_sym_encrypt('4510 123456', current_setting('app.encryption_key'))); SELECT pgp_sym_decrypt(passport::bytea, current_setting('app.encryption_key')) FROM patients WHERE id = 1; 

Comparison of Data Protection Methods

Method Reversible Search Speed Key Security
AES-256-GCM Yes No High Depends on storage
Deterministic encryption Yes Yes Medium High with HMAC
Tokenization No (replacement) Yes High Very high
Hashing (bcrypt) No No Low High

Case Study: Encryption in a Medical CRM (From Our Practice)

Client — a network of clinics with 50,000 patients. Requirement: encrypt passport data, SNILS, diagnoses. We chose AES-256-GCM + envelope encryption with HashiCorp Vault. Implemented Laravel Casts for transparent encryption. Added HMAC hash for searching by policy number. Result: response time unchanged, security audit passed, 152-FZ compliance certificate obtained. The solution scales to any number of records.

What's Included in the Work

  • Designing the encryption architecture considering business logic
  • Selecting algorithms and key management scheme (envelope encryption)
  • Integration with HashiCorp Vault or AWS KMS
  • Implementing transparent encryption at the ORM level (Laravel, Doctrine, etc.)
  • Configuring deterministic encryption for search
  • Key rotation with zero downtime
  • Access auditing and operation logging
  • Documentation for the team and developer training
  • Transferring access and test scenarios

Pricing: from $3,000 for small projects, $10,000+ for enterprise with custom integration.

Implementation Process and Timeline

  1. Designing encryption schema and key management (1-2 days).
  2. Implementing encryption at the model level (2-3 days).
  3. Integration with external key stores (5-7 days).
  4. Deterministic encryption for search (+3 days).
  5. Implementing key rotation with zero downtime (+2 days).
  6. Access auditing and operation logging (+1-2 days).
  7. Documentation and team training (+1 day).

Final timeline — from 2 weeks to 2 months, depending on data volume and business logic complexity. This investment typically pays for itself by avoiding just one major data breach fine – savings of up to $500,000 under 152-FZ or millions under GDPR.

We offer turnkey implementation starting from $3,000. Contact us for a free evaluation of your project.