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

📄 elgamalkeypairgenerator.java

📁 kmlnjlkj nlkjlkjkljl okopokipoipo oipipipo i
💻 JAVA
字号:
package org.bouncycastle.crypto.generators;import java.math.BigInteger;import org.bouncycastle.crypto.AsymmetricCipherKeyPair;import org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator;import org.bouncycastle.crypto.KeyGenerationParameters;import org.bouncycastle.crypto.params.ElGamalKeyGenerationParameters;import org.bouncycastle.crypto.params.ElGamalParameters;import org.bouncycastle.crypto.params.ElGamalPrivateKeyParameters;import org.bouncycastle.crypto.params.ElGamalPublicKeyParameters;/** * a ElGamal key pair generator. * <p> * This generates keys consistent for use with ElGamal as described in * page 164 of "Handbook of Applied Cryptography". */public class ElGamalKeyPairGenerator    implements AsymmetricCipherKeyPairGenerator{    private DHKeyGeneratorHelper helper = DHKeyGeneratorHelper.INSTANCE;        private ElGamalKeyGenerationParameters param;    public void init(        KeyGenerationParameters param)    {        this.param = (ElGamalKeyGenerationParameters)param;    }    public AsymmetricCipherKeyPair generateKeyPair()    {        BigInteger           p, x, y;        ElGamalParameters    elParams = param.getParameters();        p = elParams.getP();         x = helper.calculatePrivate(p, param.getRandom(), elParams.getL());         y = helper.calculatePublic(p, elParams.getG(), x);        return new AsymmetricCipherKeyPair(                new ElGamalPublicKeyParameters(y, elParams),                new ElGamalPrivateKeyParameters(x, elParams));    }}

⌨️ 快捷键说明

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