-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCript.php
64 lines (55 loc) · 1.74 KB
/
Cript.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
class Cript
{
//Funcao para encriptar uma determinada string
public static function encriptar($txt){
$count = 0;
$resposta = '';
while($count < strlen($txt)){
$texto = substr($txt, $count, 1);
/*
$resposta = $resposta.chr(ord($texto)+15);
*/
$texto = ord($texto);
if(strlen($texto)<3){
$texto = '0'.$texto;
}
$resposta = $resposta.$texto;
$count++;
}
return($resposta);
}
//Funcao para desencriptar uma determinada string
public static function desencriptar($txt){
$count = 0;
$resposta = '';
while($count < strlen($txt)){
$texto = substr($txt, $count, 3);
/*
$resposta = $resposta.chr(ord($texto)-15);
*/
$resposta = $resposta.chr($texto);
$count = $count+3;
}
return($resposta);
}
public static function generatePassword()
{
$length = 10;
$symbols = ['!', '#', '=', '@', '+', '('];
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
// Generate the random alphanumeric string
for ($i = 0; $i < $length; ++$i) {
$randomString .= $characters[random_int(0, $charactersLength - 1)];
}
// Make space for symbols by "cutting" the string
$randomString = substr($randomString, 0, strlen($randomString) - count($symbols));
foreach ($symbols as $key) {
// Insert each symbol at random position
$randomString = substr_replace($randomString, $key, random_int(1, strlen($randomString) - 1), 0);
}
return $randomString;
}
}