Support » Plugin: CryptX » Double quotes in hash

  • Resolved mkwprel

    (@mkwprel)


    Sometimes cryptx generates hashes with double quotes, which breaks HTML links. When $blacklist in function rw_cryptx_generate_hash (functions.php) is expanded by:
    '34', // Double quote
    this problem vanishes.

    • This topic was modified 8 months, 1 week ago by  mkwprel.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Sorry, this introduced a new bug (PHP Fatal error: Maximum function nesting level of ‘100’ reached, aborting), so I changed this function to:

    function rw_cryptx_generate_hash($string) {
    		$string = str_replace("&", "&", $string);
    		$blacklist = array(
    							'32',	// Space
    							'34',	// Double quote
    							'39',	// Single quote
    							'60',	// Less than
    							'62',	// Greater than
    							'63',	// Question mark
    							'92',	// Backslash
    							'94',	// Caret - circumflex
    							'96',	// Grave accent
    							'127',	// Delete
    						);
            $crypt	= '';
            $ascii	= 0;
    
            for ($i = 0; $i < strlen( $string ); $i++) {
    
                do {
        	    	$salt	= mt_rand(0, 3);
                    $ascii = ord ( substr ( $string, $i ) ) + $salt;
                    if (8364 <= $ascii) {
                        $ascii = 128;
                    }
    
                } while ( in_array($ascii, $blacklist) ); // blacklisted chars are impossible for hash! retry with new random...
                
                $crypt .= $salt.chr($ascii);
            }
            return $crypt;
    }

    This code runs with better performance and no recursion issues.

    Plugin Author Ralf Weber

    (@d3395)

    Hi mkwprel,

    thanks for your great work. I will implement your modified code in the next version.

    Kind regards
    Ralf

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Double quotes in hash’ is closed to new replies.