You are here

public function mylivechat::BasicEncrypt in My Live Chat 6

Same name and namespace in other branches
  1. 7 mylivechat.php \MyLiveChat::BasicEncrypt()
1 call to mylivechat::BasicEncrypt()
mylivechat::GetEncrypt in ./mylivechat.php

File

./mylivechat.php, line 191
MyLiveChat module for Drupal

Class

mylivechat
@file MyLiveChat module for Drupal

Code

public function BasicEncrypt($data, $encryptkey) {
  $EncryptLoopCount = 4;
  $vals = $this
    ->MakeArray($data, true);
  $keys = $this
    ->MakeArray($encryptkey, false);
  $len = sizeof($vals);
  $len2 = sizeof($keys);
  for ($t = 0; $t < $EncryptLoopCount; $t++) {
    for ($i = 0; $i < $len; $i++) {
      $v = $vals[$i];
      $im = ($v + $i) % 5;
      for ($x = 0; $x < $len; $x++) {
        if ($x == $i) {
          continue;
        }
        if ($x % 5 != $im) {
          continue;
        }
        for ($y = 0; $y < $len2; $y++) {
          $k = $keys[$y];
          if ($k == 0) {
            continue;
          }
          $vals[$x] += $v % $k;
        }
      }
    }
  }
  return implode('-', $vals);
}