Guest User

Untitled

a guest
Jul 20th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. <?php
  2. /***
  3. * Insert a segment of data into a string at a defined offset
  4. *
  5. * Author:
  6. * @author Jordan M
  7. *
  8. * Parameters:
  9. * @parm offset: The offset to insert data at
  10. **/
  11. private function specialEncode($offset)
  12. {
  13. //Grab the lengths of the hash and salt
  14. $len_salt = strlen($this->raw['salt']);
  15. $len_pass = strlen($this->raw['pass']);
  16.  
  17. //Get a working copy of the raw password
  18. $special_pass = $this->raw['pass'];
  19.  
  20. //The data to insert at x
  21. $ins_data = array();
  22.  
  23. //The result of the encoding
  24. $final_data = '';
  25.  
  26. //Work out where to inser what data
  27. for ($i = 0; $i < $len_pass; $i++)
  28. {
  29. //Work out the position to inser data at
  30. $ins_pos = ($i + $offset);
  31.  
  32. //Is the number a minus if so get the absolute value
  33. if ($ins_pos > $len_pass) $ins_pos = abs($i - $offset);
  34.  
  35. //Add the data to the array for storage
  36. $ins_data[$ins_pos] = $this->raw['salt'][$i];
  37. }
  38.  
  39. //Count of salt segments handled
  40. $r = 0;
  41.  
  42. foreach ($ins_data as $key => $value)
  43. {
  44. //Run aslong as the result hasnt reached the segment location
  45. for ($x = strlen($final_data); $x < $key; $x++)
  46. {
  47. //Append the data to the result
  48. $final_data .= $special_pass[ ($x + $r) ];
  49. }
  50.  
  51. //Append the segment
  52. $final_data .= $value;
  53.  
  54. //Count up the handled segments
  55. $r++;
  56. }
  57.  
  58. $this->raw['pass'] = $final_data;
  59. }
  60. ?>
Add Comment
Please, Sign In to add comment