Examples of RSAEncrypter


Examples of com.encryption.RSAEncrypter

  }

  @Override
  public void generatePublicKey(Users user) {
    try {
      RSAEncrypter encrypt = new RSAEncrypter();

      // Generate keys
      KeyPair keyPair = encrypt.generateKey();

      /*
       * 创建以用户ID为名的文件夹 在该文件夹下保存公钥和私钥文件
       */

      String dir = "D:/hdfs/" + user.getUserId().toString();
      File directory = new File(dir);

      System.out.println(directory.mkdirs());

      encrypt.saveKey(keyPair, dir + "/publicKey", dir + "/privateKey");

      /*
       * 保存公钥的url到users表中的publicKey字段
       */
      userdao.updateUserPublicKey(user, dir + "/publicKey");
View Full Code Here

Examples of com.encryption.RSAEncrypter

      /*
       * 利用公钥加密DES密钥
       */
      // 从文件中加载公钥
      RSAEncrypter encrypt = new RSAEncrypter();
      String publicKeyPath = "D:/hdfs/" + userId + "/publicKey";
      RSAPublicKey publicKey = (RSAPublicKey) encrypt.loadKey(
          publicKeyPath, 1);
      encryptedDataSecretKey = encrypt.encrypt(publicKey,
          key.getEncoded());
    } catch (Exception e) {
      e.printStackTrace();
    }
    return encryptedDataSecretKey;
View Full Code Here

Examples of com.encryption.RSAEncrypter

  public InputStream decryptFile(File privateKey, long fileId, File file) {

    /*
     * 创建RSAEncrypter对象
     */
    RSAEncrypter encrypter = new RSAEncrypter();
    /*
     * 加载私钥
     */
    String privateKeyPath = privateKey.getAbsolutePath();

    RSAPrivateKey pKey = (RSAPrivateKey) encrypter.loadKey(privateKeyPath,
        0);
    /*
     * 获取fileId对应的已加密数据密钥
     */
    HdfsFile dfsfile = filedao.findFile(fileId);
    byte[] encryptDataKey = dfsfile.getEncryptDataKey();

    /*
     * RSAEncrypter 对象调用解密模块,解密已加密的数据密钥
     */
    byte[] dataKey = encrypter.decrypt(pKey, encryptDataKey);

    /*
     * 根据数据密钥,构造DesEncrypter对象
     */
    // Create encrypter/decrypter class
View Full Code Here

Examples of com.nimbusds.jose.crypto.RSAEncrypter

      JWK jwk = jwkEntry.getValue();

      if (jwk instanceof RSAKey) {
        // build RSA encrypters and decrypters

        RSAEncrypter encrypter = new RSAEncrypter(((RSAKey) jwk).toRSAPublicKey()); // there should always at least be the public key
        encrypters.put(id, encrypter);

        if (jwk.isPrivate()) { // we can decrypt!
          RSADecrypter decrypter = new RSADecrypter(((RSAKey) jwk).toRSAPrivateKey());
          decrypters.put(id, decrypter);
View Full Code Here

Examples of com.nimbusds.jose.crypto.RSAEncrypter

    // Create the encrypted JWT object
    EncryptedJWT jwt = new EncryptedJWT(header, jwtClaims);


    // Create an encrypter with the specified public RSA key
    RSAEncrypter encrypter = new RSAEncrypter(publicKey);

    // Do the actual encryption
    jwt.encrypt(encrypter);

    // Serialise to JWT compact form
View Full Code Here

Examples of com.nimbusds.jose.crypto.RSAEncrypter

    // Create the encrypted JWT object
    EncryptedJWT jwt = new EncryptedJWT(header, jwtClaims);


    // Create an encrypter with the specified public RSA key
    RSAEncrypter encrypter = new RSAEncrypter(publicKey);

    // Do the actual encryption
    jwt.encrypt(encrypter);

    // Serialise to JWT compact form
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.