-
Notifications
You must be signed in to change notification settings - Fork 0
/
web_encryption.php
50 lines (45 loc) · 1.26 KB
/
web_encryption.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
39
40
41
42
43
44
45
46
47
48
49
50
<?php
function generate_secret_key1($value) {
$rep=$value;
while(strlen($value)<=32)
{
$value .=$rep;
// echo $value."<br>";
}
return $value;
}
function strToHex($string){
$hex='';
for ($i=0; $i < strlen($string); $i++){
$hex .= dechex(ord($string[$i]));
}
return $hex;
}
function length_check32($value) {
if(strlen($value)>32)
{
$len=strlen($value);
for($i=0;$i<32;$i++)
{
$new_value=substr($value, 0,32);
}
}
return $new_value;
}
// $query1="SELECT Password FROM User_Details WHERE Username='".$_SESSION['Username']."'";
// $query1="SELECT Password FROM User_Details WHERE Username='abhi578'";
// $res1=mysqli_query($db, $query1);
// $row=mysqli_fetch_assoc($res1);
// $key=mc_decrypt($row["Password"],ENCRYPTION_KEY);
// // $length=strlen($key);
// // echo "length is".$length."<br>";
// $key=strToHex($key);
// $password=generate_secret_key1($key);
// // echo "secret password ".$password."<br>".strlen($password)."<br>";
// $pass=length_check32($password);
// // echo "pass is ".$pass."<br>".strlen($pass);
// // echo $length."<br>".$key[0];
// $passcrypt=mc_encrypt('abc',$pass);
// // echo $passcrypt."<br>";
// $passdecrypt=mc_decrypt($passcrypt,$pass);
?>