All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.neovisionaries.ws.client.DefaultMasker Maven / Gradle / Ivy

There is a newer version: 3.0.15
Show newest version
package com.neovisionaries.ws.client;

public class DefaultMasker implements Masker {

    byte[] maskingKey;

    public DefaultMasker() {
        this.maskingKey = Misc.nextBytes(4);
    }

    public byte[] getMaskingKey() {
        return this.maskingKey;
    }

    public void mask(byte[] payload) {
        if (payload == null)
        {
            return;
        }

        for (int i = 0; i < payload.length; ++i)
        {
            // Mask
            payload[i] = (byte) ((payload[i] ^ this.maskingKey[i % 4]) & 0xFF);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy