// Encryption exponent and modulus generated via
// openssl genrsa -out private_key.pem 2048
$private_key = openssl_pkey_get_private('-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAseYGKYhnnWX8XcLX6QMxem484BG7XNtLAKSFS+Vhp43HCuVW
Flf8KdLSTOpgymXM+Dxa/wF2liaVNeA6qAj8ESRFtQLw7DqK9Vk2aihDM/j7BbPv
ljT/95atxIu6YbAGYptz2ykZOlDAPpLhUEqy0X7IIHpIXKfj3zrQd80LmZV/JlpV
iKPz1XrXKBubzGITjpTDvXrj/NB/sQc9v4c6Dm6q4QsVz8sNh5lEwyXEB64ROjvx
Ew/Ok6+H5o4KHZQeqvarHpruMrhE4hkXD5lm3lX/Sw7oxKcOvLWTKE5fXKJ2lqzu
EV0B92d5/0AJODw5fOFIH2jSDFaKTp1yutTwqQIDAQABAoIBAQCdJ45UDGs0Uc8C
aUjhUG/aLx5Z93AkFJmKZMxYgrelFAs85eIJ9QoPTG15gyekRRAwTuk4EuvWsxjn
MkG/Bcjfv8JQqNt6ZDEzku8OEqljdVUT8aP6drGU4Ch708//0kehvqA3gHQH3yQl
Yw3mJ0cW6MAUaNIaADq+ji9xVdMkhcHduCC0PxfqMhcDcnXeVt63yo2wU2K/cKnI
1/gVVd4WADxbomQ099C2PR5M/rfPHdTCjn5zSAlZcUOtibQNYMIiLiAMHbPaGiYO
+Kx1QIAXOq9Kkx75x8EKgXW7ydNyoyaNYBgizoItDnrZQ8GhcRTTlhdagYffqPcX
HsdpqZkBAoGBAOGnGz0QkeRS24Iz4mRopmIT6NbnZ8EQ5/vQPTSyq+am6I9rFx7L
O09BGJxphKV4ktWAho3FrrHqeDYMajmKcIo5nLkSVI6FwT//yGythweClbgmpiIg
V+8K33hq4ypU5PNqo6DUjEfdBaXfzryMeJxLoyESSjAir4033mDTnLrhAoGBAMnS
z0Q1Mjg4cBfFiTtZFQx48iVFrRpkg/HdF/qMv6Xc13HVEkbsK7b6rIT77Cvh80qv
5Bqql9Z3nlV2D0XbsVPBrlbEP9RhitSKPQ2QeWvFhqIOw0P+7jvxw7VuVjzpiWjV
XcF7jsxL12r7gQK3K1E5ELgFjNArFRVqzinhcvbJAoGAY3R4f+iOtLiEQRXHIYQy
WSX3SMjDJQfjh0wXveNF+qnz9Eo57Xubj2nchAvJx/illu5H37KSNZ5nD0NXijbn
NTUBS1y14f831pJQ7v1odznp7TkznfTtbNE4/2T07JJwOoz0w40Kqx3SQHKtNtMe
0ZxQsOHTyvVutGo8XCbIfGECgYBTqjCB9gt7gun08M6S67ruELVQ/jFkX4bTHPRz
ySUpfQNTDSEmhYEZuZELD+Q3zNMugvvskgufvLbGdsqeCxTXw9Kh5XkQcd87fJMS
rHGpW5kUVUpdRbE86FxZOgRF/Aoai1jyfGYWCtqiXuB8X7J1WVK09pgJM9Lprf0J
H4ypAQKBgQCwKhQmKEhYD3Php2Cuy/V/Q2EGmWRAcVG1u4r7Nj8tnXG5JEyQNPRV
dxuTdmpXrNIKm2g7N9+R1PTzzODg/utKOY9q/OI9E/RDdVFFQ6sM8XFhHuLN+So6
fgv6GlAkbuVRbwW/VYrS8/iPdSLkBU7akVNXiLZ+/suIw8oa6HFbXg==
-----END RSA PRIVATE KEY-----');
// ciphertext generated by JavaScript uses PKCS1 padding, emitted as base-64 string...
$ciphertext = $_POST['password']; // 獲取POST提交密文
// ...convert to binary.
$bin_ciphertext = base64_decode($ciphertext); // 對密文base64解碼
openssl_private_decrypt($bin_ciphertext, $plaintext, $private_key, OPENSSL_PKCS1_PADDING) // $plaintext為解密明文,解密函數為PHP自帶函數
or die("openssl_private_decrypt failed.");
?>