Skip to content

Instantly share code, notes, and snippets.

@patsuckow
patsuckow / rc4.js
Last active September 8, 2017 13:12 — forked from farhadi/rc4.js
RC4 encryption in javascript and php
/**
* RC4 symmetric cipher encryption/decryption
* @see https://gist.github.com/farhadi/2185197 and https://en.wikipedia.org/wiki/RC4
* @license Public Domain
*
* @param key - secret key for encryption/decryption
* @param str - string to be encrypted/decrypted
* @return string
*/
function rc4(key, str){
@patsuckow
patsuckow / gist:34202b4632376610ef0e
Last active September 1, 2017 12:57 — forked from tot-ra/gist:4251018
CRC calculations - Циклический избыточный код (англ. Cyclic redundancy check, CRC) — алгоритм нахождения контрольной суммы, предназначенный для проверки целостности данных.
function crc16($string, $crc = 0) {
for($x = 0; $x < strlen($string); $x++) {
$crc = $crc ^ ord($string[$x]);
echo $crc . '<br />';
for($y = 0; $y < 8; $y++) {
if(($crc & 0x0001) == 0x0001) {
$crc = (($crc >> 1) ^ 0x10589);