Hướng dẫn aes/cbc/pkcs5padding encryption in php - Mã hóa aes / cbc / pkcs5padding trong php

Cảm ơn rất nhiều vì đã đọc.

Tôi đã làm rất nhiều nghiên cứu về chủ đề này nhưng không nhận được thêm nữa.

Tôi phải giải mã dữ liệu trong PHP. Đây là đặc điểm kỹ thuật của mã hóa (và không có thêm thông số kỹ thuật nào để nhận từ người mã hóa):

Keyrength = 256 Thuật toán = AES/CBC/PKCS5PADDing KeySpec = PBKDF2WithHMACSHA1 iterations = 5000
algorithm = AES/CBC/PKCS5Padding
keyspec = PBKDF2withHmacSHA1
iterations = 5000

Những gì tôi cũng có, là một chìa khóa, dài 49 ký tự để giải mã.

Mỗi thông báo được mã hóa được cung cấp trong một mảng và nó được mã hóa base64

Dữ liệu ví dụ:

$data = [
    "iv" => "DoJQNS0WZRtWB...",
    "salt" => "zkcHInm4ewweKG81...",
    "encrypted_data" => "30MTuQEW4sVc3...",
];

Tôi đã thử điều này:

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());

Những gì tôi nhận được ở đây là

bool(false)

string(94) "error:0606508A:digital envelope routines:EVP_DecryptFinal_ex:data not multiple of block length"

Tôi không chắc đây có phải là cách tiếp cận chính xác không. Tôi cũng đã thử giải mã trực tiếp mà không cần sử dụng hàm Hash_pbkdf2 nhưng tất cả những gì tôi nhận được sau đó là rác.

Vì vậy, nếu tôi chỉ sử dụng cái này

$key = "supersecretkey";
$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);
$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING| OPENSSL_RAW_DATA, $iv);

Sau đó, tôi chỉ nhận được dữ liệu rác như

*+�l��_�y9�{(kNF7��gص��[Se!Y

Tôi sẽ đánh giá cao bất kỳ sự giúp đỡ nào về chủ đề này vì tôi đã dành rất nhiều giờ và đọc hàng tấn tài liệu.

Thật không may, tôi không nhận được bất kỳ hỗ trợ nào từ thực thể gửi dữ liệu được mã hóa.

Cảm ơn trước!

(Php 5> = 5.3.0, Php 7, Php 8)

OpenSSL_encrypt - Mã hóa dữ liệu — Encrypts dataEncrypts data

Sự mô tả

openSSL_encrypt (& nbsp; & nbsp; & nbsp; & nbsp; chuỗi ________ 0, & nbsp; & nbsp; & nbsp; & nbsp; chuỗi ________ 1, & nbsp; & nbsp; & nbsp; & nbsp; chuỗi $iv = "", & nbsp; & nbsp; 16): Chuỗi | Sai(    string $data,    string $cipher_algo,    string $passphrase,    int $options = 0,    string $iv = "",    string

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
1 =
$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
2,    string
$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
3 = "",    int
$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
4 = 16): string|false
(
    string $data,
    string $cipher_algo,
    string $passphrase,
    int $options = 0,
    string $iv = "",
    string
$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
1 =
$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
2
,
    string
$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
3 = ""
,
    int
$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
4 = 16

): string|false

Thông số

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
5

Dữ liệu thông báo rõ ràng sẽ được mã hóa.

$cipher_algo0

Phương pháp mật mã. Để biết danh sách các phương thức mật mã có sẵn, hãy sử dụng openSSL_GET_CIPHER_METHODS ().openssl_get_cipher_methods(). openssl_get_cipher_methods().

$cipher_algo1

Cụm mật khẩu. Nếu cụm mật khẩu ngắn hơn dự kiến, nó sẽ được đệm âm thầm với các ký tự $cipher_algo2; Nếu cụm mật khẩu dài hơn dự kiến, nó bị cắt ngắn.

$cipher_algo3

$cipher_algo3 là một sự khác biệt của các cờ $cipher_algo5 và $cipher_algo6.$cipher_algo5 and $cipher_algo6. $cipher_algo5 and $cipher_algo6.

$cipher_algo7

Một vectơ khởi tạo không null.

$cipher_algo8

Thẻ xác thực được truyền qua tham chiếu khi sử dụng chế độ mật mã AEAD (GCM hoặc CCM).

$cipher_algo9

Dữ liệu được xác thực bổ sung.

$passphrase0

Độ dài của xác thực $cipher_algo8. Giá trị của nó có thể nằm trong khoảng từ 4 đến 16 cho chế độ GCM.

Trả về giá trị

Trả về chuỗi được mã hóa thành công hoặc $passphrase2 khi thất bại.$passphrase2 on failure. $passphrase2 on failure.

Errors/Exceptions

Phát ra lỗi cấp $passphrase3 nếu một thuật toán mật mã không xác định được truyền qua thông số $cipher_algo0.$passphrase3 level error if an unknown cipher algorithm is passed in via the $cipher_algo0 parameter. $passphrase3 level error if an unknown cipher algorithm is passed in via the $cipher_algo0 parameter.

Phát ra lỗi cấp $passphrase3 nếu giá trị trống được truyền qua thông qua tham số $cipher_algo7.$passphrase3 level error if an empty value is passed in via the $cipher_algo7 parameter. $passphrase3 level error if an empty value is passed in via the $cipher_algo7 parameter.

Thay đổi

Phiên bảnSự mô tả
7.1.0 openSSL_encrypt (& nbsp; & nbsp; & nbsp; & nbsp; chuỗi ________ 0, & nbsp; & nbsp; & nbsp; & nbsp; chuỗi ________ 1, & nbsp; & nbsp; & nbsp; & nbsp; chuỗi $iv = "", & nbsp; & nbsp; 16): Chuỗi | Sai(    string $data,    string $cipher_algo,    string $passphrase,    int $options = 0,    string $iv = "",    string
$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
1 =
$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
2,    string
$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
3 = "",    int
$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
4 = 16): string|false

Thông số

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
5

$options0

Dữ liệu thông báo rõ ràng sẽ được mã hóa.

$options1

$cipher_algo0

Phương pháp mật mã. Để biết danh sách các phương thức mật mã có sẵn, hãy sử dụng openSSL_GET_CIPHER_METHODS ().openssl_get_cipher_methods().

$options2

$options3

$options4

$options5

$options6

$options7

$options8

$options9

$iv0

$iv1

$cipher_algo1

Cụm mật khẩu. Nếu cụm mật khẩu ngắn hơn dự kiến, nó sẽ được đệm âm thầm với các ký tự $cipher_algo2; Nếu cụm mật khẩu dài hơn dự kiến, nó bị cắt ngắn.

$iv2

$iv3

$iv4

$iv5

$iv6

$iv7

$iv8

$iv9

$iv1

$cipher_algo3

$cipher_algo3 là một sự khác biệt của các cờ $cipher_algo5 và $cipher_algo6.$cipher_algo5 and $cipher_algo6.

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
11

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
12

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
13

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
14

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
15

$cipher_algo7

Một vectơ khởi tạo không null.

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
16

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
17

$cipher_algo8

Thẻ xác thực được truyền qua tham chiếu khi sử dụng chế độ mật mã AEAD (GCM hoặc CCM).

$cipher_algo9

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
19

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
20

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
21

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
22

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
23

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
24

Dữ liệu được xác thực bổ sung.

$passphrase0

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
25

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
26

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
17

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
28

Độ dài của xác thực $cipher_algo8. Giá trị của nó có thể nằm trong khoảng từ 4 đến 16 cho chế độ GCM.

$passphrase0

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
29

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
30

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
31

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
32

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
33

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
34

$iv1

Độ dài của xác thực $cipher_algo8. Giá trị của nó có thể nằm trong khoảng từ 4 đến 16 cho chế độ GCM.

Cụm mật khẩu. Nếu cụm mật khẩu ngắn hơn dự kiến, nó sẽ được đệm âm thầm với các ký tự $cipher_algo2; Nếu cụm mật khẩu dài hơn dự kiến, nó bị cắt ngắn.

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
36

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
37

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
38

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
39

$cipher_algo3

Một vectơ khởi tạo không null.

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
40

Thẻ xác thực được truyền qua tham chiếu khi sử dụng chế độ mật mã AEAD (GCM hoặc CCM).

Cụm mật khẩu. Nếu cụm mật khẩu ngắn hơn dự kiến, nó sẽ được đệm âm thầm với các ký tự $cipher_algo2; Nếu cụm mật khẩu dài hơn dự kiến, nó bị cắt ngắn.

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
41

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
42

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
43

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
44

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
45

$iv1

$cipher_algo3

$cipher_algo9

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
47

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
48

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
49

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
50

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
51

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
52

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
53

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
54

Dữ liệu được xác thực bổ sung.

$passphrase0

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
55

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
56

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
57

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
58

Độ dài của xác thực $cipher_algo8. Giá trị của nó có thể nằm trong khoảng từ 4 đến 16 cho chế độ GCM.

Trả về giá trị

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
59

$cipher_algo00

$cipher_algo01

$cipher_algo02

$cipher_algo03

$cipher_algo04

$cipher_algo05

$cipher_algo06

$cipher_algo07

Trả về chuỗi được mã hóa thành công hoặc $passphrase2 khi thất bại.$passphrase2 on failure.

Phát ra lỗi cấp $passphrase3 nếu một thuật toán mật mã không xác định được truyền qua thông số $cipher_algo0.$passphrase3 level error if an unknown cipher algorithm is passed in via the $cipher_algo0 parameter.

Phát ra lỗi cấp $passphrase3 nếu giá trị trống được truyền qua thông qua tham số $cipher_algo7.$passphrase3 level error if an empty value is passed in via the $cipher_algo7 parameter.

$cipher_algo09

$cipher_algo10

$cipher_algo11

$cipher_algo12

$iv1

Thay đổi

Phiên bản

$cipher_algo14

$cipher_algo15

$cipher_algo16

$iv1

Các tham số $cipher_algo8, $cipher_algo9 và $passphrase0 đã được thêm vào.

$cipher_algo9

$cipher_algo18

Dữ liệu được xác thực bổ sung.

Phương pháp mật mã. Để biết danh sách các phương thức mật mã có sẵn, hãy sử dụng openSSL_GET_CIPHER_METHODS ().openssl_get_cipher_methods().

$cipher_algo19

$cipher_algo20

$cipher_algo21

$cipher_algo22

$iv1

openSSL tại mailismagic dot com ¶

7 năm trước

$cipher_algo24

Biohazard Dot Ge tại Gmail Dot Com ¶ ¶

Ẩn danh ¶

$cipher_algo25

$cipher_algo26

$cipher_algo27

$cipher_algo28

$cipher_algo29

$cipher_algo30

$cipher_algo31

$cipher_algo32

Denis tại bitrix dot ru ¶ ¶

6 năm trước

$cipher_algo33

openSSL tại mailismagic dot com ¶

7 năm trước

$cipher_algo34

$cipher_algo35

$iv1

Biohazard Dot Ge tại Gmail Dot Com ¶ ¶

Ẩn danh ¶

$cipher_algo37

$cipher_algo38

$cipher_algo39

$password = "supersecretkey";
$salt     = base64_decode($data['salt']);
$iterations = 5000;

$key_length = 32;
$is_raw_output = true;


$key = hash_pbkdf2("sha1", $password, $salt, $iterations, $key_length, true);


$iv = base64_decode($data['iv']);
$encstr = base64_decode($data['encrypted_data']);

$output = openssl_decrypt($encstr, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv);

var_dump($output);
var_dump(openssl_error_string());
57

$cipher_algo41

Denis tại bitrix dot ru ¶ ¶

6 năm trước

$cipher_algo42

Raphael ¶

6 năm trước

$cipher_algo43

Raphael ¶

$iv1

Jean-Luc ¶ ¶

4 năm trướcthe process of concealing plaintext data using the AES algorithm and an AES key length of 256 bits. In addition, 256 bits is the largest AES key length size, as well as its most mathematically complex. It is also the most difficult to crack.

naitsirch tại e dot mail dot de ¶ ¶

$cipher_algo44 used to encrypt the data. Syntax: string openssl_encrypt( string $data, string $method, string $key, $options = 0, string $iv, string $tag= NULL, string $aad, int $tag_length = 16 ) Parameters: $data: It holds the string or data which need to be encrypted.

AES CBC 256 là gì?

Mã hóa AES 256 bit là gì? Mã hóa AES 256-bit đề cập đến quá trình che giấu dữ liệu rõ ràng bằng thuật toán AES và độ dài khóa AES là 256 bit. Ngoài ra, 256 bit là kích thước chiều dài khóa AES lớn nhất, cũng như phức tạp nhất về mặt toán học. Nó cũng là khó nhất để bẻ khóa.the process of concealing plaintext data using the AES algorithm and an AES key length of 256 bits. In addition, 256 bits is the largest AES key length size, as well as its most mathematically complex. It is also the most difficult to crack..

OpenSSL_encrypt là gì?

hàm openSSL_encrypt (): hàm openSSL_encrypt () được sử dụng để mã hóa dữ liệu.Cú pháp: Chuỗi openSSL_encrypt (chuỗi $ data, chuỗi $ phương thức, chuỗi $ key, $ tùy chọn = 0, chuỗi $ iv, chuỗi $ tag = null, chuỗi $ aad, int $ tag_length = 16) tham số: $ data: nó giữchuỗi hoặc dữ liệu cần được mã hóa.used to encrypt the data. Syntax: string openssl_encrypt( string $data, string $method, string $key, $options = 0, string $iv, string $tag= NULL, string $aad, int $tag_length = 16 ) Parameters: $data: It holds the string or data which need to be encrypted.

Làm cách nào để mã hóa một tệp PHP?

Mã hóa các khối nhỏ hơn của một tệp lớn..

Tạo một vectơ khởi tạo ngẫu nhiên (iv) ....

Lưu trữ IV này ở đầu tệp được mã hóa.....

Lấy một đoạn đầu tiên, mã hóa nó với IV và lưu trữ nó.....Advanced Encryption Standard. AES encryption has three block ciphers which are AES-128 (128 bit), AES-192 (192 bit), AES-256 (256 bit). These block ciphers are named due to the key used for the encryption and decryption process.