noalyss Version-9
decrypt.php
Go to the documentation of this file.
1<?php
2
3// Store a string into the variable which
4// need to be Encrypted
5$simple_string = "Welcome to GeeksforGeeks";
6
7// Display the original string
8echo "Original String: " . $simple_string . "\n";
9
10// Store cipher method
11$ciphering = "BF-CBC";
12
13// Use OpenSSl encryption method
14$iv_length = openssl_cipher_iv_length($ciphering);
16
17// Use random_bytes() function which gives
18// randomly 16 digit values
19$encryption_iv = random_bytes(8);
20
21// Alternatively, we can use any 16 digit
22// characters or numeric for iv
23$encryption_key = openssl_digest(php_uname(), 'MD5', TRUE);
24
25// Encryption of string process starts
28
29// Display the encrypted string
30echo "Encrypted String: " . $encryption . "\n";
31
32// Decryption of string process starts
33// Used random_bytes() which gives randomly
34// 16 digit values
36
37// Store the decryption key
38$decryption_key = openssl_digest(php_uname(), 'MD5', TRUE);
39
40// Descrypt the string
41$decryption = openssl_decrypt ($encryption, $ciphering,
43
44// Display the decrypted string
45echo "Decrypted String: " . $decryption;
46
47?>
$options
Definition: decrypt.php:15
$decryption_iv
Definition: decrypt.php:35
$encryption_key
Definition: decrypt.php:23
$iv_length
Definition: decrypt.php:14
$encryption
Definition: decrypt.php:26
$decryption_key
Definition: decrypt.php:38
$ciphering
Definition: decrypt.php:11
$encryption_iv
Definition: decrypt.php:19
$simple_string
Definition: decrypt.php:5
$decryption
Definition: decrypt.php:41