|
Java example source code file (DESCrypt.java)
The DESCrypt.java Java example source code/* * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.crypto.provider; import java.security.InvalidKeyException; /** * This is the internal DES class responsible for encryption and * decryption of a byte array of size <code>DES_BLOCK_SIZE. * * @author Gigi Ankeny * @author Jan Luehe * * * @see DESConstants * @see DESCipher */ class DESCrypt extends SymmetricCipher implements DESConstants { private static final int s0p[] = { 0x00410100, 0x00010000, 0x40400000, 0x40410100, 0x00400000, 0x40010100, 0x40010000, 0x40400000, 0x40010100, 0x00410100, 0x00410000, 0x40000100, 0x40400100, 0x00400000, 0x00000000, 0x40010000, 0x00010000, 0x40000000, 0x00400100, 0x00010100, 0x40410100, 0x00410000, 0x40000100, 0x00400100, 0x40000000, 0x00000100, 0x00010100, 0x40410000, 0x00000100, 0x40400100, 0x40410000, 0x00000000, 0x00000000, 0x40410100, 0x00400100, 0x40010000, 0x00410100, 0x00010000, 0x40000100, 0x00400100, 0x40410000, 0x00000100, 0x00010100, 0x40400000, 0x40010100, 0x40000000, 0x40400000, 0x00410000, 0x40410100, 0x00010100, 0x00410000, 0x40400100, 0x00400000, 0x40000100, 0x40010000, 0x00000000, 0x00010000, 0x00400000, 0x40400100, 0x00410100, 0x40000000, 0x40410000, 0x00000100, 0x40010100, }; private static final int s1p[] = { 0x08021002, 0x00000000, 0x00021000, 0x08020000, 0x08000002, 0x00001002, 0x08001000, 0x00021000, 0x00001000, 0x08020002, 0x00000002, 0x08001000, 0x00020002, 0x08021000, 0x08020000, 0x00000002, 0x00020000, 0x08001002, 0x08020002, 0x00001000, 0x00021002, 0x08000000, 0x00000000, 0x00020002, 0x08001002, 0x00021002, 0x08021000, 0x08000002, 0x08000000, 0x00020000, 0x00001002, 0x08021002, 0x00020002, 0x08021000, 0x08001000, 0x00021002, 0x08021002, 0x00020002, 0x08000002, 0x00000000, 0x08000000, 0x00001002, 0x00020000, 0x08020002, 0x00001000, 0x08000000, 0x00021002, 0x08001002, 0x08021000, 0x00001000, 0x00000000, 0x08000002, 0x00000002, 0x08021002, 0x00021000, 0x08020000, 0x08020002, 0x00020000, 0x00001002, 0x08001000, 0x08001002, 0x00000002, 0x08020000, 0x00021000, }; private static final int s2p[] = { 0x20800000, 0x00808020, 0x00000020, 0x20800020, 0x20008000, 0x00800000, 0x20800020, 0x00008020, 0x00800020, 0x00008000, 0x00808000, 0x20000000, 0x20808020, 0x20000020, 0x20000000, 0x20808000, 0x00000000, 0x20008000, 0x00808020, 0x00000020, 0x20000020, 0x20808020, 0x00008000, 0x20800000, 0x20808000, 0x00800020, 0x20008020, 0x00808000, 0x00008020, 0x00000000, 0x00800000, 0x20008020, 0x00808020, 0x00000020, 0x20000000, 0x00008000, 0x20000020, 0x20008000, 0x00808000, 0x20800020, 0x00000000, 0x00808020, 0x00008020, 0x20808000, 0x20008000, 0x00800000, 0x20808020, 0x20000000, 0x20008020, 0x20800000, 0x00800000, 0x20808020, 0x00008000, 0x00800020, 0x20800020, 0x00008020, 0x00800020, 0x00000000, 0x20808000, 0x20000020, 0x20800000, 0x20008020, 0x00000020, 0x00808000, }; private static final int s3p[] = { 0x00080201, 0x02000200, 0x00000001, 0x02080201, 0x00000000, 0x02080000, 0x02000201, 0x00080001, 0x02080200, 0x02000001, 0x02000000, 0x00000201, 0x02000001, 0x00080201, 0x00080000, 0x02000000, 0x02080001, 0x00080200, 0x00000200, 0x00000001, 0x00080200, 0x02000201, 0x02080000, 0x00000200, 0x00000201, 0x00000000, 0x00080001, 0x02080200, 0x02000200, 0x02080001, 0x02080201, 0x00080000, 0x02080001, 0x00000201, 0x00080000, 0x02000001, 0x00080200, 0x02000200, 0x00000001, 0x02080000, 0x02000201, 0x00000000, 0x00000200, 0x00080001, 0x00000000, 0x02080001, 0x02080200, 0x00000200, 0x02000000, 0x02080201, 0x00080201, 0x00080000, 0x02080201, 0x00000001, 0x02000200, 0x00080201, 0x00080001, 0x00080200, 0x02080000, 0x02000201, 0x00000201, 0x02000000, 0x02000001, 0x02080200, }; private static final int s4p[] = { 0x01000000, 0x00002000, 0x00000080, 0x01002084, 0x01002004, 0x01000080, 0x00002084, 0x01002000, 0x00002000, 0x00000004, 0x01000004, 0x00002080, 0x01000084, 0x01002004, 0x01002080, 0x00000000, 0x00002080, 0x01000000, 0x00002004, 0x00000084, 0x01000080, 0x00002084, 0x00000000, 0x01000004, 0x00000004, 0x01000084, 0x01002084, 0x00002004, 0x01002000, 0x00000080, 0x00000084, 0x01002080, 0x01002080, 0x01000084, 0x00002004, 0x01002000, 0x00002000, 0x00000004, 0x01000004, 0x01000080, 0x01000000, 0x00002080, 0x01002084, 0x00000000, 0x00002084, 0x01000000, 0x00000080, 0x00002004, 0x01000084, 0x00000080, 0x00000000, 0x01002084, 0x01002004, 0x01002080, 0x00000084, 0x00002000, 0x00002080, 0x01002004, 0x01000080, 0x00000084, 0x00000004, 0x00002084, 0x01002000, 0x01000004, }; private static final int s5p[] = { 0x10000008, 0x00040008, 0x00000000, 0x10040400, 0x00040008, 0x00000400, 0x10000408, 0x00040000, 0x00000408, 0x10040408, 0x00040400, 0x10000000, 0x10000400, 0x10000008, 0x10040000, 0x00040408, 0x00040000, 0x10000408, 0x10040008, 0x00000000, 0x00000400, 0x00000008, 0x10040400, 0x10040008, 0x10040408, 0x10040000, 0x10000000, 0x00000408, 0x00000008, 0x00040400, 0x00040408, 0x10000400, 0x00000408, 0x10000000, 0x10000400, 0x00040408, 0x10040400, 0x00040008, 0x00000000, 0x10000400, 0x10000000, 0x00000400, 0x10040008, 0x00040000, 0x00040008, 0x10040408, 0x00040400, 0x00000008, 0x10040408, 0x00040400, 0x00040000, 0x10000408, 0x10000008, 0x10040000, 0x00040408, 0x00000000, 0x00000400, 0x10000008, 0x10000408, 0x10040400, 0x10040000, 0x00000408, 0x00000008, 0x10040008, }; private static final int s6p[] = { 0x00000800, 0x00000040, 0x00200040, 0x80200000, 0x80200840, 0x80000800, 0x00000840, 0x00000000, 0x00200000, 0x80200040, 0x80000040, 0x00200800, 0x80000000, 0x00200840, 0x00200800, 0x80000040, 0x80200040, 0x00000800, 0x80000800, 0x80200840, 0x00000000, 0x00200040, 0x80200000, 0x00000840, 0x80200800, 0x80000840, 0x00200840, 0x80000000, 0x80000840, 0x80200800, 0x00000040, 0x00200000, 0x80000840, 0x00200800, 0x80200800, 0x80000040, 0x00000800, 0x00000040, 0x00200000, 0x80200800, 0x80200040, 0x80000840, 0x00000840, 0x00000000, 0x00000040, 0x80200000, 0x80000000, 0x00200040, 0x00000000, 0x80200040, 0x00200040, 0x00000840, 0x80000040, 0x00000800, 0x80200840, 0x00200000, 0x00200840, 0x80000000, 0x80000800, 0x80200840, 0x80200000, 0x00200840, 0x00200800, 0x80000800, }; private static final int s7p[] = { 0x04100010, 0x04104000, 0x00004010, 0x00000000, 0x04004000, 0x00100010, 0x04100000, 0x04104010, 0x00000010, 0x04000000, 0x00104000, 0x00004010, 0x00104010, 0x04004010, 0x04000010, 0x04100000, 0x00004000, 0x00104010, 0x00100010, 0x04004000, 0x04104010, 0x04000010, 0x00000000, 0x00104000, 0x04000000, 0x00100000, 0x04004010, 0x04100010, 0x00100000, 0x00004000, 0x04104000, 0x00000010, 0x00100000, 0x00004000, 0x04000010, 0x04104010, 0x00004010, 0x04000000, 0x00000000, 0x00104000, 0x04100010, 0x04004010, 0x04004000, 0x00100010, 0x04104000, 0x00000010, 0x00100010, 0x04004000, 0x04104010, 0x00100000, 0x04100000, 0x04000010, 0x00104000, 0x00004010, 0x04004010, 0x04100000, 0x00000010, 0x04104000, 0x00104010, 0x00000000, 0x04000000, 0x04100010, 0x00004000, 0x00104010, }; private static final int permRight0[] = { 0x00000000, 0x40000000, 0x00400000, 0x40400000, 0x00004000, 0x40004000, 0x00404000, 0x40404000, 0x00000040, 0x40000040, 0x00400040, 0x40400040, 0x00004040, 0x40004040, 0x00404040, 0x40404040, }; private static final int permLeft1[] = { 0x00000000, 0x40000000, 0x00400000, 0x40400000, 0x00004000, 0x40004000, 0x00404000, 0x40404000, 0x00000040, 0x40000040, 0x00400040, 0x40400040, 0x00004040, 0x40004040, 0x00404040, 0x40404040, }; private static final int permRight2[] = { 0x00000000, 0x10000000, 0x00100000, 0x10100000, 0x00001000, 0x10001000, 0x00101000, 0x10101000, 0x00000010, 0x10000010, 0x00100010, 0x10100010, 0x00001010, 0x10001010, 0x00101010, 0x10101010, }; private static final int permLeft3[] = { 0x00000000, 0x10000000, 0x00100000, 0x10100000, 0x00001000, 0x10001000, 0x00101000, 0x10101000, 0x00000010, 0x10000010, 0x00100010, 0x10100010, 0x00001010, 0x10001010, 0x00101010, 0x10101010, }; private static final int permRight4[] = { 0x00000000, 0x04000000, 0x00040000, 0x04040000, 0x00000400, 0x04000400, 0x00040400, 0x04040400, 0x00000004, 0x04000004, 0x00040004, 0x04040004, 0x00000404, 0x04000404, 0x00040404, 0x04040404, }; private static final int permLeft5[] = { 0x00000000, 0x04000000, 0x00040000, 0x04040000, 0x00000400, 0x04000400, 0x00040400, 0x04040400, 0x00000004, 0x04000004, 0x00040004, 0x04040004, 0x00000404, 0x04000404, 0x00040404, 0x04040404, }; private static final int permRight6[] = { 0x00000000, 0x01000000, 0x00010000, 0x01010000, 0x00000100, 0x01000100, 0x00010100, 0x01010100, 0x00000001, 0x01000001, 0x00010001, 0x01010001, 0x00000101, 0x01000101, 0x00010101, 0x01010101, }; private static final int permLeft7[] = { 0x00000000, 0x01000000, 0x00010000, 0x01010000, 0x00000100, 0x01000100, 0x00010100, 0x01010100, 0x00000001, 0x01000001, 0x00010001, 0x01010001, 0x00000101, 0x01000101, 0x00010101, 0x01010101, }; private static final int permRight8[] = { 0x00000000, 0x80000000, 0x00800000, 0x80800000, 0x00008000, 0x80008000, 0x00808000, 0x80808000, 0x00000080, 0x80000080, 0x00800080, 0x80800080, 0x00008080, 0x80008080, 0x00808080, 0x80808080, }; private static final int permLeft9[] = { 0x00000000, 0x80000000, 0x00800000, 0x80800000, 0x00008000, 0x80008000, 0x00808000, 0x80808000, 0x00000080, 0x80000080, 0x00800080, 0x80800080, 0x00008080, 0x80008080, 0x00808080, 0x80808080, }; private static final int permRightA[] = { 0x00000000, 0x20000000, 0x00200000, 0x20200000, 0x00002000, 0x20002000, 0x00202000, 0x20202000, 0x00000020, 0x20000020, 0x00200020, 0x20200020, 0x00002020, 0x20002020, 0x00202020, 0x20202020, }; private static final int permLeftB[] = { 0x00000000, 0x20000000, 0x00200000, 0x20200000, 0x00002000, 0x20002000, 0x00202000, 0x20202000, 0x00000020, 0x20000020, 0x00200020, 0x20200020, 0x00002020, 0x20002020, 0x00202020, 0x20202020, }; private static final int permRightC[] = { 0x00000000, 0x08000000, 0x00080000, 0x08080000, 0x00000800, 0x08000800, 0x00080800, 0x08080800, 0x00000008, 0x08000008, 0x00080008, 0x08080008, 0x00000808, 0x08000808, 0x00080808, 0x08080808, }; private static final int permLeftD[] = { 0x00000000, 0x08000000, 0x00080000, 0x08080000, 0x00000800, 0x08000800, 0x00080800, 0x08080800, 0x00000008, 0x08000008, 0x00080008, 0x08080008, 0x00000808, 0x08000808, 0x00080808, 0x08080808, }; private static final int permRightE[] = { 0x00000000, 0x02000000, 0x00020000, 0x02020000, 0x00000200, 0x02000200, 0x00020200, 0x02020200, 0x00000002, 0x02000002, 0x00020002, 0x02020002, 0x00000202, 0x02000202, 0x00020202, 0x02020202, }; private static final int permLeftF[] = { 0x00000000, 0x02000000, 0x00020000, 0x02020000, 0x00000200, 0x02000200, 0x00020200, 0x02020200, 0x00000002, 0x02000002, 0x00020002, 0x02020002, 0x00000202, 0x02000202, 0x00020202, 0x02020202, }; /* * Initial Permutation */ private static final int initPermLeft0[] = { 0x00000000, 0x00008000, 0x00000000, 0x00008000, 0x00000080, 0x00008080, 0x00000080, 0x00008080, 0x00000000, 0x00008000, 0x00000000, 0x00008000, 0x00000080, 0x00008080, 0x00000080, 0x00008080, }; private static final int initPermRight0[] = { 0x00000000, 0x00000000, 0x00008000, 0x00008000, 0x00000000, 0x00000000, 0x00008000, 0x00008000, 0x00000080, 0x00000080, 0x00008080, 0x00008080, 0x00000080, 0x00000080, 0x00008080, 0x00008080, }; private static final int initPermLeft1[] = { 0x00000000, 0x80000000, 0x00000000, 0x80000000, 0x00800000, 0x80800000, 0x00800000, 0x80800000, 0x00000000, 0x80000000, 0x00000000, 0x80000000, 0x00800000, 0x80800000, 0x00800000, 0x80800000, }; private static final int initPermRight1[] = { 0x00000000, 0x00000000, 0x80000000, 0x80000000, 0x00000000, 0x00000000, 0x80000000, 0x80000000, 0x00800000, 0x00800000, 0x80800000, 0x80800000, 0x00800000, 0x00800000, 0x80800000, 0x80800000, }; private static final int initPermLeft2[] = { 0x00000000, 0x00004000, 0x00000000, 0x00004000, 0x00000040, 0x00004040, 0x00000040, 0x00004040, 0x00000000, 0x00004000, 0x00000000, 0x00004000, 0x00000040, 0x00004040, 0x00000040, 0x00004040, }; private static final int initPermRight2[] = { 0x00000000, 0x00000000, 0x00004000, 0x00004000, 0x00000000, 0x00000000, 0x00004000, 0x00004000, 0x00000040, 0x00000040, 0x00004040, 0x00004040, 0x00000040, 0x00000040, 0x00004040, 0x00004040, }; private static final int initPermLeft3[] = { 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00400000, 0x40400000, 0x00400000, 0x40400000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00400000, 0x40400000, 0x00400000, 0x40400000, }; private static final int initPermRight3[] = { 0x00000000, 0x00000000, 0x40000000, 0x40000000, 0x00000000, 0x00000000, 0x40000000, 0x40000000, 0x00400000, 0x00400000, 0x40400000, 0x40400000, 0x00400000, 0x00400000, 0x40400000, 0x40400000, }; private static final int initPermLeft4[] = { 0x00000000, 0x00002000, 0x00000000, 0x00002000, 0x00000020, 0x00002020, 0x00000020, 0x00002020, 0x00000000, 0x00002000, 0x00000000, 0x00002000, 0x00000020, 0x00002020, 0x00000020, 0x00002020, }; private static final int initPermRight4[] = { 0x00000000, 0x00000000, 0x00002000, 0x00002000, 0x00000000, 0x00000000, 0x00002000, 0x00002000, 0x00000020, 0x00000020, 0x00002020, 0x00002020, 0x00000020, 0x00000020, 0x00002020, 0x00002020, }; private static final int initPermLeft5[] = { 0x00000000, 0x20000000, 0x00000000, 0x20000000, 0x00200000, 0x20200000, 0x00200000, 0x20200000, 0x00000000, 0x20000000, 0x00000000, 0x20000000, 0x00200000, 0x20200000, 0x00200000, 0x20200000, }; private static final int initPermRight5[] = { 0x00000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x20000000, 0x20000000, 0x00200000, 0x00200000, 0x20200000, 0x20200000, 0x00200000, 0x00200000, 0x20200000, 0x20200000, }; private static final int initPermLeft6[] = { 0x00000000, 0x00001000, 0x00000000, 0x00001000, 0x00000010, 0x00001010, 0x00000010, 0x00001010, 0x00000000, 0x00001000, 0x00000000, 0x00001000, 0x00000010, 0x00001010, 0x00000010, 0x00001010, }; private static final int initPermRight6[] = { 0x00000000, 0x00000000, 0x00001000, 0x00001000, 0x00000000, 0x00000000, 0x00001000, 0x00001000, 0x00000010, 0x00000010, 0x00001010, 0x00001010, 0x00000010, 0x00000010, 0x00001010, 0x00001010, }; private static final int initPermLeft7[] = { 0x00000000, 0x10000000, 0x00000000, 0x10000000, 0x00100000, 0x10100000, 0x00100000, 0x10100000, 0x00000000, 0x10000000, 0x00000000, 0x10000000, 0x00100000, 0x10100000, 0x00100000, 0x10100000, }; private static final int initPermRight7[] = { 0x00000000, 0x00000000, 0x10000000, 0x10000000, 0x00000000, 0x00000000, 0x10000000, 0x10000000, 0x00100000, 0x00100000, 0x10100000, 0x10100000, 0x00100000, 0x00100000, 0x10100000, 0x10100000, }; private static final int initPermLeft8[] = { 0x00000000, 0x00000800, 0x00000000, 0x00000800, 0x00000008, 0x00000808, 0x00000008, 0x00000808, 0x00000000, 0x00000800, 0x00000000, 0x00000800, 0x00000008, 0x00000808, 0x00000008, 0x00000808, }; private static final int initPermRight8[] = { 0x00000000, 0x00000000, 0x00000800, 0x00000800, 0x00000000, 0x00000000, 0x00000800, 0x00000800, 0x00000008, 0x00000008, 0x00000808, 0x00000808, 0x00000008, 0x00000008, 0x00000808, 0x00000808, }; private static final int initPermLeft9[] = { 0x00000000, 0x08000000, 0x00000000, 0x08000000, 0x00080000, 0x08080000, 0x00080000, 0x08080000, 0x00000000, 0x08000000, 0x00000000, 0x08000000, 0x00080000, 0x08080000, 0x00080000, 0x08080000, }; private static final int initPermRight9[] = { 0x00000000, 0x00000000, 0x08000000, 0x08000000, 0x00000000, 0x00000000, 0x08000000, 0x08000000, 0x00080000, 0x00080000, 0x08080000, 0x08080000, 0x00080000, 0x00080000, 0x08080000, 0x08080000, }; private static final int initPermLeftA[] = { 0x00000000, 0x00000400, 0x00000000, 0x00000400, 0x00000004, 0x00000404, 0x00000004, 0x00000404, 0x00000000, 0x00000400, 0x00000000, 0x00000400, 0x00000004, 0x00000404, 0x00000004, 0x00000404, }; private static final int initPermRightA[] = { 0x00000000, 0x00000000, 0x00000400, 0x00000400, 0x00000000, 0x00000000, 0x00000400, 0x00000400, 0x00000004, 0x00000004, 0x00000404, 0x00000404, 0x00000004, 0x00000004, 0x00000404, 0x00000404, }; private static final int initPermLeftB[] = { 0x00000000, 0x04000000, 0x00000000, 0x04000000, 0x00040000, 0x04040000, 0x00040000, 0x04040000, 0x00000000, 0x04000000, 0x00000000, 0x04000000, 0x00040000, 0x04040000, 0x00040000, 0x04040000, }; private static final int initPermRightB[] = { 0x00000000, 0x00000000, 0x04000000, 0x04000000, 0x00000000, 0x00000000, 0x04000000, 0x04000000, 0x00040000, 0x00040000, 0x04040000, 0x04040000, 0x00040000, 0x00040000, 0x04040000, 0x04040000, }; private static final int initPermLeftC[] = { 0x00000000, 0x00000200, 0x00000000, 0x00000200, 0x00000002, 0x00000202, 0x00000002, 0x00000202, 0x00000000, 0x00000200, 0x00000000, 0x00000200, 0x00000002, 0x00000202, 0x00000002, 0x00000202, }; private static final int initPermRightC[] = { 0x00000000, 0x00000000, 0x00000200, 0x00000200, 0x00000000, 0x00000000, 0x00000200, 0x00000200, 0x00000002, 0x00000002, 0x00000202, 0x00000202, 0x00000002, 0x00000002, 0x00000202, 0x00000202, }; private static final int initPermLeftD[] = { 0x00000000, 0x02000000, 0x00000000, 0x02000000, 0x00020000, 0x02020000, 0x00020000, 0x02020000, 0x00000000, 0x02000000, 0x00000000, 0x02000000, 0x00020000, 0x02020000, 0x00020000, 0x02020000, }; private static final int initPermRightD[] = { 0x00000000, 0x00000000, 0x02000000, 0x02000000, 0x00000000, 0x00000000, 0x02000000, 0x02000000, 0x00020000, 0x00020000, 0x02020000, 0x02020000, 0x00020000, 0x00020000, 0x02020000, 0x02020000, }; private static final int initPermLeftE[] = { 0x00000000, 0x00000100, 0x00000000, 0x00000100, 0x00000001, 0x00000101, 0x00000001, 0x00000101, 0x00000000, 0x00000100, 0x00000000, 0x00000100, 0x00000001, 0x00000101, 0x00000001, 0x00000101, }; private static final int initPermRightE[] = { 0x00000000, 0x00000000, 0x00000100, 0x00000100, 0x00000000, 0x00000000, 0x00000100, 0x00000100, 0x00000001, 0x00000001, 0x00000101, 0x00000101, 0x00000001, 0x00000001, 0x00000101, 0x00000101, }; private static final int initPermLeftF[] = { 0x00000000, 0x01000000, 0x00000000, 0x01000000, 0x00010000, 0x01010000, 0x00010000, 0x01010000, 0x00000000, 0x01000000, 0x00000000, 0x01000000, 0x00010000, 0x01010000, 0x00010000, 0x01010000, }; private static final int initPermRightF[] = { 0x00000000, 0x00000000, 0x01000000, 0x01000000, 0x00000000, 0x00000000, 0x01000000, 0x01000000, 0x00010000, 0x00010000, 0x01010000, 0x01010000, 0x00010000, 0x00010000, 0x01010000, 0x01010000, }; /* * the encryption key array after expansion and permutation */ byte[] expandedKey = null; /* * Are we encrypting or decrypting? */ boolean decrypting = false; /** * Returns this cipher's block size. * * @return this cipher's block size */ int getBlockSize() { return DES_BLOCK_SIZE; } void init(boolean decrypting, String algorithm, byte[] rawKey) throws InvalidKeyException { this.decrypting = decrypting; if (!algorithm.equalsIgnoreCase("DES")) { throw new InvalidKeyException("Wrong algorithm: DES required"); } if (rawKey.length != DES_BLOCK_SIZE) { throw new InvalidKeyException("Wrong key size"); } expandKey(rawKey); } /** * Performs encryption operation. * * <p>The input plain text Other Java examples (source code examples)Here is a short list of links related to this Java DESCrypt.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.