Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function rc4($pt, $key) {
- $s = array();
- for ($i=0; $i<256; $i++) {
- $s[$i] = $i;
- }
- $j = 0;
- $x = null;
- for ($i=0; $i<256; $i++) {
- $j = ($j + $s[$i] + ord($key[$i % strlen($key)])) % 256;
- $x = $s[$i];
- $s[$i] = $s[$j];
- $s[$j] = $x;
- }
- $i = 0;
- $j = 0;
- $ct = '';
- $y = null;
- for ($y=0; $y<strlen($pt); $y++) {
- $i = ($i + 1) % 256;
- $j = ($j + $s[$i]) % 256;
- $x = $s[$i];
- $s[$i] = $s[$j];
- $s[$j] = $x;
- $ct .= $pt[$y] ^ chr($s[($s[$i] + $s[$j]) % 256]);
- }
- return $ct;
- }
- function encrypt_data($input, $key_seed) {
- $bin = rc4($input, $key_seed);
- return base64_encode($bin);
- }
- function decrypt_data($input, $key_seed) {
- $bin = base64_decode($input);
- return rc4($bin, $key_seed);
- }
Advertisement
Add Comment
Please, Sign In to add comment