⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testsafer.java

📁 jpeg2000编解码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    }    private void test4() throws Exception {        int[] data = {  193, 162, 137, 119,  71, 111,   4, 122,   221,  53, 132, 163,  31, 251,  91, 187,  193, 162, 137, 119,  71, 111,   4, 122,   221,  53, 132, 163,  31, 251,  91, 187,  200,   7, 221, 209, 159, 188, 204, 148,   108, 182, 178,  60,  21,   6, 172,   3,  135,  38,  14,  54, 116,  19, 125, 236,    12,  65, 190, 138, 183,  64,  84,  94,  211,  57, 211,  91, 134,  90, 189, 173,   198,  52,  54,  78, 218, 211,  10,  64,  160, 250,  24, 252,  43,  62, 176,  51,   229,  82, 255, 241, 155, 211,  23, 185,  144,  30, 255,  20,  82, 191,  37, 197,   241,  45,  53, 149, 201, 159,  67,  72,   56, 230,  77, 191, 110,  15, 137, 110,   125, 143,   1,  74, 144,  36, 128, 254,   42,  66,  86, 239, 123, 207, 118, 129,    79,  15, 246, 165,  44,  92, 253,  96,  229, 105, 211, 191, 109, 129, 236, 199,   134, 174, 205, 197, 236, 183, 160, 119,   39,  48,  34, 113,  23,  99, 138, 156,   241,  88,  87, 154, 155, 138, 208,  73,   76, 235, 164, 163,  78, 161,  71,  16,    35,  35,  55,  87,   0, 148, 112, 232,   98, 175,  26, 239, 137,  77,  16, 106,    26, 246,  43,  38, 237,  84, 201,  35,  213, 220, 132, 203,  53,  48, 202, 119,   192,  74, 167, 216,   1, 111, 138,  10,   25,  68, 167, 158, 226, 226, 255,  64,   179, 148,  31,   8,  78, 243, 131, 146,  144,  89, 114, 186, 228,  43,  99, 173,   198, 192, 243,   9,  44, 153,  27, 235,    6,  33, 118,   4, 173, 100,  48, 242,    92,  98, 216, 213, 149, 225, 238, 128,  198,  93, 197, 243, 203, 210, 227, 203,   191, 225, 181, 137, 184,  73, 136,  66    };        out.println("\nSAFER in ECB mode: " +            "safer -e -ecb -kx 08070605040302010807060504030201 -r 12\n");        byte[] output = new byte[data.length];        for (int i = 0; i < data.length; i++)            output[i] = (byte)data[i];        Cipher alg = Cipher.getInstance("SAFER", "Cryptix");        ((Parameterized) alg).setParameter("variant", "K-128");        ((Parameterized) alg).setParameter("rounds", new Integer(12));        // Our implementation, automatically duplicates an 8-byte        // key. The following for loop code is functionally equivalent        // to that used in test3() above.                byte[] b = new byte[16];        for (int i = 0; i < 8; i++)            b[i] = b[8 + i] = (byte)(8 - i);        RawSecretKey key = new RawSecretKey("SAFER", b);                    alg.initEncrypt(key);        compareIt(alg.crypt(input), output);    }        private void test5() throws Exception {        int[] data = {   18, 137,   3,  44, 179, 185,  93, 230,   127, 241,  49,  31, 136, 105, 240,  21,   18, 137,   3,  44, 179, 185,  93, 230,   127, 241,  49,  31, 136, 105, 240,  21,   90,  66, 146,  57, 213,  20, 160,  29,    97,  17, 200, 117, 225, 187,  79, 170,  248, 157,   7, 200, 220, 237,  22, 209,    88, 114,  63, 233,  77, 121,  72,  88,  210,  88, 247, 213, 135, 182,  73, 127,   253,  46, 224,  20,  23, 240, 166, 236,  105,  19, 251, 246, 255, 225,  70,  32,   198,  78,  25,  12,  13,  10, 181, 136,  111, 165, 163, 110, 119, 225, 189,  19,   141, 195,  52, 246, 182,  99,  86, 150,  115, 139, 227,  14,  40, 161,   6, 252,   156, 253,  33, 133, 167, 121, 148, 124,   17,  53,  17, 194,  46, 121,  54, 223,   158, 235,  45,  23, 192,  88,  20,  55,  189,  10,   9,  37, 150, 229,  58, 181,   154,  45,   0, 118,  16, 195, 222,   6,  118, 246, 201,  66, 234, 100,  64,  66,   188,  83,  41, 128, 222, 163, 141,  21,   70, 176, 202, 249, 121,   7,  61, 102,   205,  76,  17, 232,   2,  17, 235,  10,  252, 150, 232,  84, 114, 108, 208, 236,   170, 110,  90, 179,   5,  33, 242, 223,   23, 229, 149, 166, 172, 184, 101, 219,    38, 244, 232,  18,  24, 130,  67,  39,   67, 230,   3,  18,  82, 130, 164, 238,   195,  12, 225,  83,  31, 113,  52,  79,  200,  93,  22, 110,  35,   5, 185, 123,    91, 245, 245,  54, 146, 154, 172, 124,  222,  91,  96, 112, 125,  17, 206, 170,    18, 128, 119,  30,  11, 223,  41, 238,  246, 179, 146,  99,  52, 210,  95, 140,   158, 173, 224,  60, 208, 158, 118, 190    };        out.println("\nSAFER in ECB mode: " +            "safer -e -ecb -kx 01020304050607080807060504030201 -r 12\n");        byte[] output = new byte[data.length];        for (int i = 0; i < data.length; i++)            output[i] = (byte)data[i];        Cipher alg = Cipher.getInstance("SAFER", "Cryptix");        ((Parameterized) alg).setParameter("variant", "K-128");        ((Parameterized) alg).setParameter("rounds", new Integer(12));        byte[] b = new byte[16];        for (int i = 0; i < 8; i++)            b[i] = b[15 - i] = (byte)(i + 1);        RawSecretKey key = new RawSecretKey("SAFER", b);                    alg.initEncrypt(key);        compareIt(alg.crypt(input), output);    }        private void test6() throws Exception {        int[] data = {  251, 144, 115, 211,  68,  87,  59,  12,    21,  27, 255,   2, 173,  17, 191,  45,  251, 144, 115, 211,  68,  87,  59,  12,    21,  27, 255,   2, 173,  17, 191,  45,  229, 117,  85, 247,  74, 153, 163,  85,   206, 201, 191,  54, 204, 202,  90,  44,   14, 245,  31, 156,  84, 150, 204, 139,   229,  23, 225,  47, 154, 235,  35, 238,  112, 249, 114,  21, 162, 199, 168, 244,   120, 175, 114, 205,  14, 104, 178,  57,   93,  59, 252,  73,  34, 161, 109, 125,    72,   0,  40,  87, 137,  72, 206, 118,  239,  96, 232, 157, 143, 171, 180,  46,   112, 194,  16, 200, 111, 135, 159,  41,  144, 137, 177, 229,  60,  50, 245,  33,   248, 206,  90, 198, 166,   6,  27, 197,  125, 101, 158,  44, 132, 176, 113,  88,   173, 224,  16, 183,   6, 201, 162, 225,  154, 190,  44, 133, 190,  45, 118,  20,   235, 196, 169, 198, 194,  92, 242,  21,  171, 165, 233,  90, 101, 139, 244,  71,    60,  15,  47,  40,   1,  64, 110,   2,  200,   4, 112, 190, 166,  64, 150, 228,     3, 181,  54, 127, 143, 171,  32, 251,  213, 179, 250, 249, 101, 249, 212,  76,   245, 128, 115, 148,  90, 208, 164,  63,   55,  89,  10, 141,  56, 240, 101,  33,    30,  95, 252, 243, 141, 126,  56,  48,    4, 156, 148, 205, 121, 113,  55,  66,   205, 139,  22,  85,  61,  21, 156,  24,   42, 119, 129, 122, 163,  88, 186,  39,    45, 126,  27,   6, 241, 142, 162,  99,  110, 166, 153, 205, 149, 254, 171,  33,    22,   9, 109, 173, 137,  91,  33,  80,  171, 133, 102,  45, 255, 215,   6, 173,    74, 138, 120, 243,  70,  12,  82,  99    };        out.println("\nSAFER in ECB mode: " +            "safer -e -ecb -kx 0000000000000001 -s -r 6\n");        byte[] output = new byte[data.length];        for (int i = 0; i < data.length; i++)            output[i] = (byte)data[i];        Cipher alg = Cipher.getInstance("SAFER", "Cryptix");        ((Parameterized) alg).setParameter("variant", "SK-64");        ((Parameterized) alg).setParameter("rounds", new Integer(6));        byte[] b = new byte[8];        b[7] = 0x01;        RawSecretKey key = new RawSecretKey("SAFER", b);                    alg.initEncrypt(key);        compareIt(alg.crypt(input), output);    }        private void test7() throws Exception {        int[] data = {  233, 169, 154, 148,  75,  45, 142,  87,    95, 206, 155, 162,   5, 132,  56, 199,  233, 169, 154, 148,  75,  45, 142,  87,    95, 206, 155, 162,   5, 132,  56, 199,  214,  50, 195, 106, 117, 166, 122,  92,   202,   4, 216,  87,   7, 223, 170,  73,  239, 104, 126,  77, 226, 113, 115, 185,   215,  50, 152, 187,  52, 171,   2,  40,  118, 110, 129, 126, 164, 124,  17,  85,   166, 157, 153, 102,  90, 153, 200, 181,  187, 164,  17,  94,  83, 113,   2, 198,   244,  30, 189,  16,  46,  78, 220,  81,   30, 161,  31, 115, 123, 181,  76,  50,    97, 220, 154, 210,  80, 130, 205,  14,   10,  53, 212,  47,  81,  17, 140, 146,   161,  12, 200,  63,  30, 168,  72, 156,  150, 110, 208, 196, 183,  97, 199, 143,   222, 126, 117, 146,   9, 117, 194, 157,   54,  39, 223,  55, 138, 168, 147, 186,    83, 140, 115, 208,  37, 135,  74, 118,   84, 231,  43, 162, 215,  68, 197, 102,    87, 245,  93,  15, 126, 182, 248, 254,  248, 243, 173, 225, 128, 150, 240,  15,   118, 218,  46,  45, 123,  73, 235, 239,  160, 248, 224,  97,  22, 245, 178,   3,   208,  69,  47, 191, 162, 228,  56,  91,  230, 126, 112,  90,  86, 183,   8, 111,    71, 200, 228,  99, 129,  93, 146,  28,   30,  98, 245, 232,  81,  32, 102,   5,     9, 125, 187, 182, 230,  41,  29, 142,  241,  20, 113, 121,  35, 186, 240,  65,   182, 188, 127, 113,  95, 112, 142,  75,  108, 153, 144, 201,  95,   1,  58,   9,   142, 129, 195, 241, 242, 216, 189, 136,  106,   8, 133, 209, 126, 138,   9,   6,   171, 176, 206,  27, 154,   8,   2, 227    };        out.println("\nSAFER in ECB mode: " +            "safer -e -ecb -kx 0102030405060708 -s -r 6\n");        byte[] output = new byte[data.length];        for (int i = 0; i < data.length; i++)            output[i] = (byte)data[i];        Cipher alg = Cipher.getInstance("SAFER", "Cryptix");        ((Parameterized) alg).setParameter("variant", "SK-64");        ((Parameterized) alg).setParameter("rounds", new Integer(6));        byte[] b = new byte[8];        for (int i = 0; i < 8; i++)            b[i] = (byte)(i + 1);        RawSecretKey key = new RawSecretKey("SAFER", b);                    alg.initEncrypt(key);        compareIt(alg.crypt(input), output);    }        private void test8() throws Exception {        int[] data = {  249, 176, 171,  27, 220,  97, 189, 230,    65,  76,  84,  90, 182, 153,  74, 247,  249, 176, 171,  27, 220,  97, 189, 230,    65,  76,  84,  90, 182, 153,  74, 247,   46, 146, 221,  48, 220,  60, 180,  23,   126, 253, 126, 141, 249, 122, 226, 165,  167,  55, 252,  75,  43,  44,  32, 108,   245, 218,  93,  55, 108,  36,  89, 124,  224, 133, 135, 250, 141,  48,  29, 210,    19, 171, 202,  56,  13, 241, 111,  42,  152, 144, 163,  18, 147,  83, 195,  34,     0, 232, 179, 239, 235,  84, 142, 245,  191, 254,  57, 202,  59,  68, 135, 208,   239, 233, 213, 101, 207, 170,  27, 143,  220, 121,  54, 138, 190,  38, 116, 209,    21, 216,  16, 131, 193, 245,  80, 235,   22, 190, 171,  51, 230,  85,  77, 139,    96, 228,  66, 240,   3, 245,  93, 200,   72, 128,  35, 100, 251, 106,  45, 244,    26, 248, 224, 195, 223,  40, 122, 156,  191, 188, 191, 143, 160, 162,  43, 153,    13, 117,   4, 196, 145, 105, 132, 253,  158, 170,  77, 241, 224, 239, 244,  69,    76, 193,  72,  56,  57, 158,  83,  45,  192, 246, 218,  38, 125, 229,   8, 117,    70,  69,  63,   2, 162,  32, 183,  54,  223, 182, 226,  88,  82, 232,  35,  61,   168,  28, 135, 156, 128, 131,  61, 148,  233, 182, 210, 131, 190, 235,  68, 124,   190, 196,  43, 154, 237, 244,  18,  45,    2, 253, 241, 158,  59, 231, 160, 155,   169, 212, 113, 243, 149,  27,  57, 194,  173, 110, 113, 131,  48,  19,  34,  87,   250, 153,  35, 119,  30, 188, 187,  54,   76,  87, 204, 211, 240, 253,  28, 145,    36,  80,  23,  12, 155, 214, 209, 129    };        out.println("\nSAFER in ECB mode: " +            "safer -e -ecb -kx 00000000000000010000000000000001 -s -r 10\n");        byte[] output = new byte[data.length];        for (int i = 0; i < data.length; i++)            output[i] = (byte)data[i];        Cipher alg = Cipher.getInstance("SAFER", "Cryptix");        ((Parameterized) alg).setParameter("variant", "SK-128"); // this is the default mode        ((Parameterized) alg).setParameter("rounds", new Integer(10));        // we'll rely on the fact that our implementation doubles an 8-byte key        byte[] b = new byte[8];        b[7] = 0x01;        RawSecretKey key = new RawSecretKey("SAFER", b);                    alg.initEncrypt(key);        compareIt(alg.crypt(input), output);    }    // Following the sequence in <code>check.ref</code> here we were missing these sets:    //    safer -e -ecb -kx 01020304050607080000000000000000 -s -r 10    //    safer -e -ecb -kx 00000000000000000102030405060708 -s -r 10    //    private void test8B() throws Exception {        int[] data = {  104, 156,  77,  53,  69, 225, 184, 209,   255, 120,  17, 228, 179, 167,  46, 113,  104, 156,  77,  53,  69, 225, 184, 209,   255, 120,  17, 228, 179, 167,  46, 113,   33,  61,  56, 177,   4, 208,  50, 242,   238,   4,  78, 221, 252,  76, 168,  10,   22, 134, 153,  52,  41, 133, 112,  72,   181,  42,  55,  74, 190,  66, 151, 146,   66,  68,   7, 201,   2, 129, 170,  21,    14,  95, 190, 213,  76, 127, 109, 170,  249, 206, 170, 180, 195,  20, 104, 238,    91, 113, 245,  77,  53,   2, 223, 241,  155,  24,  66, 130,   4, 126, 162,  41,   170, 158,  37, 243, 177, 237, 105, 112,  220,  14,  61,  40, 203, 182,  95,  68,    50, 255, 202, 143, 248,  91,  14, 228,  240, 219, 224, 117,  84, 139, 108,  61,   177, 102, 218,   0, 240, 245,  99,  77,  212, 190,  68, 114, 138, 164,  75,  82,   172, 215,  24, 124,  16, 132, 222, 200,   46, 189, 146, 205, 132,  30, 113,  49,   104, 137,  97, 109, 214,  46,  58,  80,   22,  26,  14,  65, 234, 138, 119,  54,    82,  39,  65, 175, 248,   1,  77, 239,   65,  36, 107, 101, 241, 220, 106, 250,   105, 122, 127,  42, 189, 106,  53,  16,  187, 116, 162, 228, 204, 228, 245,  44,     1,  43,  53, 173,   0, 164,  56, 120,   70,  56,  66,  57, 248,  93,  49,  31,   104, 116,  72, 177, 245, 232,   3, 232,  230, 175,  79, 155, 111, 193,  49, 121,   220, 165, 203,  52, 252,  86, 207,  47,  174,  48, 118,  70, 109,  66, 204, 143,    54, 169,  90, 239, 124,  66,  54,  86,   22, 176, 155, 176,  70, 221,  48,  27,   172,  61,  99, 141,  93, 145,  48,  30,    };        out.println("\nSAFER in ECB mode: " +            "safer -e -ecb -kx 01020304050607080000000000000000 -s -r 10\n");        byte[] output = new byte[data.length];        for (int i = 0; i < data.length; i++)            output[i] = (byte)data[i];        Cipher alg = Cipher.getInstance("SAFER", "Cryptix");//        ((Parameterized) alg).setParameter("variant", "SK-128"); // this is the default variant//        ((Parameterized) alg).setParameter("rounds", new Integer(10)); // this is also the default        byte[] b = new byte[16];        for (int i = 0; i < 8; i++) { b[i] = (byte)(i + 1);  b[i + 8] = (byte)0; }        RawSecretKey key = new RawSecretKey("SAFER", b);                    alg.initEncrypt(key);        compareIt(alg.crypt(input), output);    }    private void test8C() throws Exception {        int[] data = {    1, 194, 254,  49,   5, 168,  29,  16,    73, 201, 157, 152, 165, 188,  89,   8,    1, 194, 254,  49,   5, 168,  29,  16,    73, 201, 157, 152, 165, 188,  89,   8,  142,  84,  64,   7, 168, 177,  52, 112,   147, 150, 146, 127, 150,   8, 125,  55,  236,   6, 197, 172,  69, 115, 158, 128,    74,  84,  34, 162,  82, 158,  27, 176,   90, 191,  47,  85,  40,  97, 159, 237,   228, 194, 116,   4,   4,  35, 156,  62,   49,  80, 122,  19,  20, 124, 173,  88,   191, 103, 205, 164, 106, 165, 178, 133,   79,  83, 120, 127, 124, 254,  28, 244,   173, 182, 157, 212, 240, 120, 247,  90,  224, 185, 108, 101, 183,  79,  83,  86,   222, 190, 208, 162, 228, 186,   9,  55,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -