simple xor buffer folder
194886
function fold(count, buf)
{
  if(!count || buf.length % 2) return buf;
  var ret = buf.slice(0,buf.length/2);
  for(i = 0; i < ret.length; i++) ret[i] = ret[i] ^ buf[i+ret.length];
  return fold(count-1,ret);
}
81388
def bitop_xor(self, dest, key, *keys):
        """"""
        return self.execute(b'BITOP', b'XOR', dest, key, *keys)
1251591
private static byte[] xor(byte[] bytes) {
        byte[] xor_bytes = null;

        if (bytes != null) {
            xor_bytes = new byte[bytes.length];

            for (int i = 0; i < bytes.length; i++) {
                xor_bytes[i] = (byte) (XOR_MASK ^ bytes[i]);
            }
        }

        return xor_bytes;
    }
546483
def getBuffer(x):
    
    b = bytes(x)
    return (c_ubyte * len(b)).from_buffer_copy(bytes(x))
91191
function bufferToScript(buffer, enc) {
    if (buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) { // UTF8 BOM sequence, see http://en.wikipedia.org/wiki/Byte_order_mark
        buffer = buffer.slice(3, buffer.length - 3);
    }

    var script = buffer.toString(enc);

    script = script.replace(/^\s*#!/g, "//$&"); // UNIX-style shebang, see http://en.wikipedia.org/wiki/Shebang_(Unix)
    return script;
}
1254302
def main_encrypt(A):
    ""
    profile = get_profile(A)
    localKeys = profile.get('local keys', [])
    if not localKeys:
        localKeys = [make_lock_securely(warn_only = A.ignore_entropy)]
    else:
        localKeys = [crypto.UserLock.private_from_b64(k['private_key']) for k in localKeys]
    # First key is considered "main"
    userKey = localKeys[0]
    print("User ID:", userKey.userID)
    if not os.path.exists(A.path):
        error_out("File or directory '{}' does not exist.".format(A.path))
    # Create, fetch or error out for recipient list:
    recipients = resolve_recipients(profile, A.recipient)
    recipients.append(userKey)
    print("Recipients:", *set(k.userID if isinstance(k, crypto.UserLock) else k for k in recipients))
    # Do files OR folders
    if os.path.isfile(A.path):
        crypted = encrypt_file(A.path, userKey, recipients)
    elif os.path.isdir(A.path):
        crypted = encrypt_folder(A.path, userKey, recipients)
    else:
        error_out("Specified path '{}' is neither a file nor a folder.".format(A.path))
    if A.base64:
        crypted = crypto.b64encode(crypted)
    if not A.output:
        A.output = hex(int.from_bytes(os.urandom(6),'big'))[2:] + ".minilock"
    print("Saving output to", A.output)
    with open(A.output, "wb") as O:
        O.write(crypted)
751797
function xor_64_2(a, b)
	{
		return new Int_64(
			a.highOrder ^ b.highOrder,
			a.lowOrder ^ b.lowOrder
		);
	}
1029337
void xor(LongBitSet other) {
		assert other.numWords <= numWords : "numWords=" + numWords + ", other.numWords=" + other.numWords;
		int pos = Math.min(numWords, other.numWords);
		while (--pos >= 0) {
			bits[pos] ^= other.bits[pos];
		}
	}
1272005
def xor_app(parser, cmd, args):  # pragma: no cover
    

    parser.add_argument(
        '-d', '--dec',
        help='interpret the key as a decimal integer',
        dest='type',
        action='store_const',
        const=int
    )
    parser.add_argument(
        '-x', '--hex',
        help='interpret the key as an hexadecimal integer',
        dest='type',
        action='store_const',
        const=lambda v: int(v, 16)
    )
    parser.add_argument('key', help='the key to xor the value with')
    parser.add_argument('value', help='the value to xor, read from stdin if omitted', nargs='?')

    args = parser.parse_args(args)
    if args.type is not None:
        args.key = args.type(args.key)

    return xor(args.key, pwnypack.main.binary_value_or_stdin(args.value))
579822
function blockChecksums(fs, path, size, callback) {
  var cache = {};

  fs.readFile(path, function (err, data) {
    if (!err) {
      // cache file
      cache[path] = data;
    } else if (err && err.code === 'ENOENT') {
      cache[path] = [];
    } else {
      return callback(err);
    }

    var length = cache[path].length;
    var incr = size;
    var start = 0;
    var end = incr > length ? length : incr;
    var blockIndex = 0;
    var result = [];
    var chunk;
    var weak;
    var strong;

    while (start < length) {
      chunk  = cache[path].slice(start, end);
      weak   = calcWeak32(chunk).sum;
      strong = md5sum(chunk);

      result.push({
        index: blockIndex,
        weak: weak,
        strong: strong
      });
      // update slice indices
      start += incr;
      end = (end + incr) > length ? length : end + incr;
      // update block index
      blockIndex++;
    }

    callback(null, result);
  });
}
6958
def xor(s, pad):
    ''''''
    from itertools import cycle
    s = bytearray(force_bytes(s, encoding='latin-1'))
    pad = bytearray(force_bytes(pad, encoding='latin-1'))
    return binary_type(bytearray(x ^ y for x, y in zip(s, cycle(pad))))
858604
def _xor8(ins):
    
    op1, op2 = tuple(ins.quad[2:])
    if _int_ops(op1, op2) is not None:
        op1, op2 = _int_ops(op1, op2)

        output = _8bit_oper(op1)  # True or X = not X
        if op2 == 0:  # False xor X = X
            output.append('push af')
            return output

        output.append('sub 1')
        output.append('sbc a, a')
        output.append('push af')
        return output

    output = _8bit_oper(op1, op2)
    output.append('call __XOR8')
    output.append('push af')
    REQUIRES.add('xor8.asm')

    return output
578357
function (prf, iterationCount) {

        var xor = function (l, r) {
            var i;
            for (i = 0; i < l.length; i++) {
                l[i] = l[i] ^ r[i];
            }
            return l;
        };

        var _F = function (password, salt, iterationCount, i) {
            var k;
            var Ti = new Uint8Array(new ArrayBuffer(prf.hmacLength()));
            var U = new Uint8Array(new ArrayBuffer(salt.length + 4));
            U.set(salt, 0);
            U.set(convertToUInt32(i), salt.length);
            for (k = 1; k <= iterationCount; k++) {
                prf.setKey(password);
                prf.update(U);
                U = new Uint8Array(prf.finalize());
                Ti = xor(Ti, U);
            }
            return Ti;
        };

        var derive = function (password, salt, len) {
            var i, l, tmpBuf;
            if (len > prf.hmacLength() * 0xFFFFFFFF) {
                throw "Derived key length too long";
            }
            l = Math.ceil(len / prf.hmacLength());
            tmpBuf = new Uint8Array(new ArrayBuffer(len * prf.hmacLength()));
            for (i = 1; i <= l; i++) {
                tmpBuf.set(_F(password, salt, iterationCount, i), prf.hmacLength() * (i - 1));
            }
            return tmpBuf.buffer.slice(0, len);
        };

        return {
            deriveKey: function (password, salt, len) {
                return derive(convertToUint8Array(password), convertToUint8Array(salt), len);
            }
        };
    }
32650
function decryptRaw (buffer, passphrase, progressCallback, scryptParams) {
  // 39 bytes: 2 bytes prefix, 37 bytes payload
  if (buffer.length !== 39) throw new Error('Invalid BIP38 data length')
  if (buffer.readUInt8(0) !== 0x01) throw new Error('Invalid BIP38 prefix')
  scryptParams = scryptParams || SCRYPT_PARAMS

  // check if BIP38 EC multiply
  var type = buffer.readUInt8(1)
  if (type === 0x43) return decryptECMult(buffer, passphrase, progressCallback, scryptParams)
  if (type !== 0x42) throw new Error('Invalid BIP38 type')

  passphrase = Buffer.from(passphrase, 'utf8')

  var flagByte = buffer.readUInt8(2)
  var compressed = flagByte === 0xe0
  if (!compressed && flagByte !== 0xc0) throw new Error('Invalid BIP38 compression flag')

  var N = scryptParams.N
  var r = scryptParams.r
  var p = scryptParams.p

  var salt = buffer.slice(3, 7)
  var scryptBuf = scrypt(passphrase, salt, N, r, p, 64, progressCallback)
  var derivedHalf1 = scryptBuf.slice(0, 32)
  var derivedHalf2 = scryptBuf.slice(32, 64)

  var privKeyBuf = buffer.slice(7, 7 + 32)
  var decipher = aes.createDecipheriv('aes-256-ecb', derivedHalf2, NULL)
  decipher.setAutoPadding(false)
  decipher.end(privKeyBuf)

  var plainText = decipher.read()
  var privateKey = xor(derivedHalf1, plainText)

  // verify salt matches address
  var d = BigInteger.fromBuffer(privateKey)
  var address = getAddress(d, compressed)
  var checksum = hash256(address).slice(0, 4)
  assert.deepEqual(salt, checksum)

  return {
    privateKey: privateKey,
    compressed: compressed
  }
}
746447
function createSHAHash(buffer, algorithm) {
    var logger = getLogger('utility.createSHA1Hash');
    var sha1sum = crypto.createHash(algorithm || 'sha1');
    if (require('util').isArray(buffer)) {
        if (logger.isDebugEnabled()) {
            logger.debug('It\'s an Array of buffers');
        }
        for (var i = 0; i < buffer.length; i++) {
            sha1sum.update(buffer[i]);
        }
    } else {
        if (logger.isDebugEnabled()) {
            logger.debug('It\'s only one buffer');
        }
        sha1sum.update(buffer);
    }
    return sha1sum.digest();
}
1159165
function (sessionKey) {
        //The first 16 bytes (MSB first) will be the key, the next 16 bytes (MSB first) will be the initialization vector (IV), and the final 8 bytes (MSB first) will be the salt.
        var key = new Buffer(16); //just the key... +8); //key plus salt
        var iv = new Buffer(16); //initialization vector

        sessionKey.copy(key, 0, 0, 16); //copy the key
        sessionKey.copy(iv, 0, 16, 32); //copy the iv

        return new CryptoStream({
            key: key,
            iv: iv,
            encrypt: false
        });
    }
633684
def path
      out_buffer = FFI::MemoryPointer.new(:uchar, 2048)
      io_size = FFI::MemoryPointer.new(:uint32)
      io_size.put_uint32(0, out_buffer.size)

      status = Sec.SecKeychainGetPath(self,io_size, out_buffer)
      Sec.check_osstatus(status)

      out_buffer.read_string(io_size.get_uint32(0)).force_encoding(Encoding::UTF_8)
    end