我很遗憾地问你关于这么多问题的技巧.我有一个关于RSA crypthography的问题.我已经检查了有关此问题的其他主题,但我没有找到任何有用的答案.我希望你能帮助我.
我想读取一个文件,将其包含,然后解密,并将这些解密的字节放在一个新文件中.
我实际上可以: - 获取文件的字节 - 加密它
我有一个例外:javax.crypto.BadPaddingException:数据必须从零开始.
这是我的代码:
package com.bodom.ghosty;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import java.io.*;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.*;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.RSAPrivateKeySpec;
import java.security.spec.RSAPublicKeySpec;
import java.util.Scanner;
public class EncryptionUtil {
private final PrivateKey privateKey;
private final PublicKey publicKey;
/**
* Build an EncryptionUtil object
*
* @param keyPair The KeyPair used for Ghosty
*/
public EncryptionUtil (KeyPair keyPair) {
this.privateKey = keyPair.getPrivate(); …Run Code Online (Sandbox Code Playgroud)