集册 Java实例教程 将4x4 2D字节数组转换为串联的线性字节数组

将4x4 2D字节数组转换为串联的线性字节数组

欢马劈雪     最近更新时间:2020-01-02 10:19:05

405
将4x4 2D字节数组转换为串联的线性字节数组
// 来自 时   代    Java - nowjava.com

//package com.nowjava;


public class Main {

    /**

     * Converts a 4x4 2D byte array to a cocatenated linear byte array

     * As defined in FIPS197

     * 

     * Idea of linearising/squaring arrays taken from watne.seis720.project.AES_Utilities

     * Watne uses array indexes and some unpleasant looking maths, so I've rewritten it

     * to use arraycopy instead, which is much more efficient.

     * 

     * @param array - 4x4 2D byte array

     * @return array - linearised byte array

     */

    public static byte[] array4xToArray(byte[][] array) {

        byte[] array1x = new byte[16];


        for (
展开阅读全文