小编Ric*_*nda的帖子

哪个提供商负责AES / CTR / NoPadding?

有关我的实施的信息

下面的代码片段突出显示了我当前使用AES密码和CTR操作模式实现的加密对象。

import javax.crypto.Cipher;

public abstract class Crypto {

    private static final String CIPHER_ALGORITHM = "AES/CTR/NoPadding";
    private String AesKeyString = "ByWelFHCgFqivFZrWs89LQ==";

    private void setKey() throws NoSuchAlgorithmException{
        byte[] keyBytes;
        keyBytes = Base64.getDecoder().decode(AesKeyString);
        aesKey = new SecretKeySpec(keyBytes, "AES");
    }

    protected byte[] execute(int mode, byte[] target, byte[] iv) 
            throws Exception{
        Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
        IvParameterSpec ivSpec = new IvParameterSpec(iv);
        cipher.init(mode, aesKey, ivSpec);
        return cipher.doFinal(target);
    }

}
Run Code Online (Sandbox Code Playgroud)

就我而言getInstance()方法从支持此转换的第一个Provider返回一个实现请求的转换的Cipher对象。

以下是包含我所有可用提供商的列表:

    SUN
    Alg.Alias.Signature.SHA1/DSA    SHA1withDSA
    Alg.Alias.Signature.1.2.840.10040.4.3   SHA1withDSA
    Alg.Alias.Signature.DSS SHA1withDSA
    SecureRandom.SHA1PRNG ImplementedIn Software
    KeyStore.JKS    sun.security.provider.JavaKeyStore$DualFormatJKS …
Run Code Online (Sandbox Code Playgroud)

java cryptography jce aes ctr-mode

6
推荐指数
1
解决办法
1971
查看次数

标签 统计

aes ×1

cryptography ×1

ctr-mode ×1

java ×1

jce ×1