shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/RC4EncryptAlgorithm.java
/**
     * Initialize SBOX with given key, Key-scheduling algorithm.
     *
     * @param key key
     * @return sBox int array
     * @see <a href="http://en.wikipedia.org/wiki/RC4#Key-scheduling_algorithm_.28KSA.29">Wikipedia. Init sBox</a>
     */
Initialize SBOX with given key, Key-scheduling algorithm.
@param key key
@return sBox int array
@see Wikipedia. Init sBox
Initialize SBOX with given key Key - scheduling algorithm . @param key key @return sBox int array @see Wikipedia . Init sBox
private int[] initSBox(final byte[] key) {
        int[] result = new int[SBOX_LENGTH];
        int j = 0;
        for (int i = 0; i < SBOX_LENGTH; i++) {
            result[i] = i;
        }
        for (int i = 0; i < SBOX_LENGTH; i++) {
            j = (j + result[i] + (key[i % key.length]) & 0xFF) % SBOX_LENGTH;
            swap(i, j, result);
        }
        return result;
    }
private int [ ] initSBox ( final byte [ ] key ) { int [ ] result = new int [ SBOX_LENGTH ] ; int j = 0 ; for ( int i = 0 ; i < SBOX_LENGTH ; i ++ ) { result [ i ] = i ; } for ( int i = 0 ; i < SBOX_LENGTH ; i ++ ) { j = ( j + result [ i ] + ( key [ i % key . length ] ) & 0xFF ) % SBOX_LENGTH ; swap ( i , j , result ) ; } return result ; }
Initialize SBOX with given key, Key-scheduling algorithm.
Initialize SBOX with given key Key - scheduling algorithm .