Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /***
- * Insert a segment of data into a string at a defined offset
- *
- * Author:
- * @author Jordan M
- *
- * Parameters:
- * @parm offset: The offset to insert data at
- **/
- private function specialEncode($offset)
- {
- //Grab the lengths of the hash and salt
- $len_salt = strlen($this->raw['salt']);
- $len_pass = strlen($this->raw['pass']);
- //Get a working copy of the raw password
- $special_pass = $this->raw['pass'];
- //The data to insert at x
- $ins_data = array();
- //The result of the encoding
- $final_data = '';
- //Work out where to inser what data
- for ($i = 0; $i < $len_pass; $i++)
- {
- //Work out the position to inser data at
- $ins_pos = ($i + $offset);
- //Is the number a minus if so get the absolute value
- if ($ins_pos > $len_pass) $ins_pos = abs($i - $offset);
- //Add the data to the array for storage
- $ins_data[$ins_pos] = $this->raw['salt'][$i];
- }
- //Count of salt segments handled
- $r = 0;
- foreach ($ins_data as $key => $value)
- {
- //Run aslong as the result hasnt reached the segment location
- for ($x = strlen($final_data); $x < $key; $x++)
- {
- //Append the data to the result
- $final_data .= $special_pass[ ($x + $r) ];
- }
- //Append the segment
- $final_data .= $value;
- //Count up the handled segments
- $r++;
- }
- $this->raw['pass'] = $final_data;
- }
- ?>
Add Comment
Please, Sign In to add comment