0
이 코드에서 answer을 사용하고 있습니다. 서명 및 서명 확인 방법에 대한 예제가 있지만 어떻게 Bouncycastle을 사용하여 이러한 종류의 서명을 해독 할 수 있습니까? java.security.Signature
클래스에는 이러한 메소드가 없습니다.디지털 서명 탄력성 암호 해독
이 코드에서 answer을 사용하고 있습니다. 서명 및 서명 확인 방법에 대한 예제가 있지만 어떻게 Bouncycastle을 사용하여 이러한 종류의 서명을 해독 할 수 있습니까? java.security.Signature
클래스에는 이러한 메소드가 없습니다.디지털 서명 탄력성 암호 해독
당신이 당신의 질문에서 참조하는 서명/검증 샘플 대신 bouncycastle을 사용하여 암호화/해독 샘플을 찾고 있다는 것을 의미한다고 생각합니다. 그것을하기 위해서 당신은 java.security.Signature
대신에 javax.crypto.Cipher
클래스를 사용할 수 있습니다. 나는 ECB 모드에서 AES 알고리즘을 사용하는 간단한 예제를 제공합니다 (많은 암호 알고리즘, 동작 모드 등이 있습니다).
희망이 도움이,
: 몇 가지 테스트 클래스 서로 다른 암호 구현을 테스트하기 위해이 곳import java.security.Key;
import java.security.Security;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
public class CipherBasicSample
{
public static void main(String args[]) throws Exception
{
Security.addProvider(new BouncyCastleProvider());
// text to cipher
String secret = "secret";
// create the key to cipher an decipher
KeyGenerator kg = KeyGenerator.getInstance("AES","BC");
kg.init(128);
SecretKey sk = kg.generateKey();
Key key = new SecretKeySpec(sk.getEncoded(), "AES");
// get a cipher instance
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding", "BC");
// init to encrypt mode
cipher.init(Cipher.ENCRYPT_MODE, key);
// encrypt the text
cipher.update(secret.getBytes());
byte[] secretEncrypt = cipher.doFinal();
System.out.println("Encrypt text: " + new String(secretEncrypt));
// get a cipher instance
Cipher decipher = Cipher.getInstance("AES/ECB/PKCS5Padding", "BC");
// init to decrypt mode
decipher.init(Cipher.DECRYPT_MODE, key);
// decrypt the text
decipher.update(secretEncrypt);
byte[] secretDecrypt = decipher.doFinal();
System.out.println("Encrypt text: " + new String(secretDecrypt));
}
}
은 또한 당신은 bc.prov 소스 코드를 확인하실 수 있습니다