-
Notifications
You must be signed in to change notification settings - Fork 0
/
alfin_crypt.php
38 lines (34 loc) · 1.08 KB
/
alfin_crypt.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/**
* Returns an encrypted & utf8-encoded
*/
function encrypt($pure_string, $encryption_key) {
$iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$encrypted_string = mcrypt_encrypt(MCRYPT_BLOWFISH, $encryption_key, utf8_encode($pure_string), MCRYPT_MODE_ECB, $iv);
return $encrypted_string;
}
/**
* Returns decrypted original string
*/
function decrypt($encrypted_string, $encryption_key) {
$iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$decrypted_string = mcrypt_decrypt(MCRYPT_BLOWFISH, $encryption_key, $encrypted_string, MCRYPT_MODE_ECB, $iv);
return $decrypted_string;
}
/**
* Alfin encrypt and return to hexa
*/
function alfin_e($kalimat){
$kunci = "Aku Sangat Sayang Kamu :-D";
return bin2hex(encrypt($kalimat, $kunci));
}
/**
* Alfin decrypt and return to original
*/
function alfin_d($kalimat){
$kunci = "Aku Sangat Sayang Kamu :-D";
return decrypt(hex2bin($kalimat), $kunci);
}
?>