gpt4 book ai didi

java - 查找公钥的长度

转载 作者:行者123 更新时间:2023-12-02 05:10:55 25 4
gpt4 key购买 nike

我正在尝试查找 DSA 公钥的长度,但找不到方法 .length,我已确保我具有正确的导入,但似乎没有上类。代码片段如下,有没有特殊的函数可以找到这个?

 //my imports 
import java.util.*;
import java.io.*;
import javax.crypto.*;
import javax.crypto.spec.*;
import java.security.*;

public boolean SelObj(int k, PublicKey c) throws java.rmi.RemoteException{
for(int j =1; j<c.bitLength(); ++j) {
//some code
}
}

最佳答案

字节数组编码的位长:

c.getEncoded().length * Byte.SIZE

整数值的位长度:

import java.security.interfaces.DSAPublicKey

((DSAPublicKey) c).getY().bitLength()

关于java - 查找公钥的长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27348643/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com