com_simpledownload /site/helpers/encryption.php

Language PHP Lines 82
MD5 Hash e473a160d4c3632aeff38b4f94d53554
Repository https://github.com/hjoelr/com_simpledownload.git View Raw File View Project SPDX
 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
 * SimpleDownload default encryption functions.  These are really only intended
 * for educational purposes and for areas where security is not highly important.
 * 
 * @package    Joomla.Joelrowley.Com
 * @subpackage Components
 * @link http://joomla.joelrowley.com/
 * @license		GNU/GPL
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

function jcrypt($str, $offset=3) {
    $max = strlen($str);
    for($i = 0; $i < $max; $i++){
        //if the letter is upper case, keep it uppercase
        if(ord($str[$i]) >= 65 && ord($str[$i]) <= 90){
            if((ord($str[$i])+$offset) > 90) {
                $crypt .= chr(65+((ord($str[$i])+$offset)-91));
            } else if((ord($str[$i])+$offset) < 65) {
                $crypt .= chr(90+((ord($str[$i])+$offset)-64));
            } else {
                $crypt .= chr(ord($str[$i])+$offset);
            }
        }
        
        //if the letter is lower case, keep it lower case
        else if(ord($str[$i]) >= 97 && ord($str[$i]) <= 122){
            if((ord($str[$i])+$offset) > 122) {
                $crypt .= chr(97+((ord($str[$i])+$offset)-123));
            } else if((ord($str[$i])+$offset) < 97) {
                $crypt .= chr(122+((ord($str[$i])+$offset)-96));
            } else {
                $crypt .= chr(ord($str[$i])+$offset);
            }
        }
        
    	else if(ord($str[$i]) >= 48 && ord($str[$i]) <= 57){
            if((ord($str[$i])+$offset) > 57) {
                $crypt .= chr(48+((ord($str[$i])+$offset)-58));
            } else {
                $crypt .= chr(ord($str[$i])+$offset);
            }
        }
        
        else {
        	$crypt .= chr(ord($str[$i])+$offset);
        	// in case of path separator
        	/*if (ord($str[$i]) == 47) {
        		$crypt .= '#';
        	// in case of period
        	} else if (ord($str[$i]) == 46) {
        		$crypt .= '*';
        	// in case of dash (-)
        	} else if (ord($str[$i]) == 45) {
        		$crypt .= '!';
        	} else {
        		echo "<- " . $i . " - " . ord($str[$i]) . " ->";
        	}*/
            //die("You can only use letters.");
            //$crypt .= chr(ord($str[$i])+$offset);
        }
    }
    //$crypt = strtoupper($crypt);
    return $crypt;
}

function jdecrypt($str) {
	return jcrypt($str, -3);
}

function jcrypt64($str) {
	return base64_encode($str);
}

function jdecrypt64($str) {
	return base64_decode($str);
}

?> 
Back to Top