Java tutorial
//package com.java2s; /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ public class Main { public static final int CRYPTO_KEY_LENGTH_BYTES = 32; public static byte[] unwrapkB(byte[] unwrapkB, byte[] wrapkB) { if (unwrapkB == null) { throw new IllegalArgumentException("unwrapkB must not be null"); } if (wrapkB == null) { throw new IllegalArgumentException("wrapkB must not be null"); } if (unwrapkB.length != CRYPTO_KEY_LENGTH_BYTES || wrapkB.length != CRYPTO_KEY_LENGTH_BYTES) { throw new IllegalArgumentException( "unwrapkB and wrapkB must be " + CRYPTO_KEY_LENGTH_BYTES + " bytes long"); } byte[] kB = new byte[CRYPTO_KEY_LENGTH_BYTES]; for (int i = 0; i < wrapkB.length; i++) { kB[i] = (byte) (wrapkB[i] ^ unwrapkB[i]); } return kB; } }