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

📄 streamciphervectortest.java

📁 J2ME加密算法的代码!里面包括常用的算法
💻 JAVA
字号:
package org.bouncycastle.crypto.test;import org.bouncycastle.crypto.CipherParameters;import org.bouncycastle.crypto.StreamCipher;import org.bouncycastle.util.encoders.Hex;import org.bouncycastle.util.test.SimpleTest;/** * a basic test that takes a stream cipher, key parameter, and an input * and output string. */public class StreamCipherVectorTest    extends SimpleTest{    int                 id;    StreamCipher        cipher;    CipherParameters    param;    byte[]              input;    byte[]              output;    public StreamCipherVectorTest(        int                 id,        StreamCipher        cipher,        CipherParameters    param,        String              input,        String              output)    {        this.id = id;        this.cipher = cipher;        this.param = param;        this.input = Hex.decode(input);        this.output = Hex.decode(output);    }    public String getName()    {        return cipher.getAlgorithmName() + " Vector Test " + id;    }    public void performTest()    {        cipher.init(true, param);        byte[]  out = new byte[input.length];        cipher.processBytes(input, 0, input.length, out, 0);        if (!areEqual(out, output))        {            fail("failed.", new String(Hex.encode(output)) , new String(Hex.encode(out)));        }        cipher.init(false, param);        cipher.processBytes(output, 0, output.length, out, 0);        if (!areEqual(input, out))        {            fail("failed reversal");        }    }}

⌨️ 快捷键说明

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