java - 如何从客户端发送的服务器解密文件
问题描述
我有以下家庭作业项目。需要使用 ftps 创建 server-client 并将文件上传到服务器。在上传文件之前必须加密。另一端的服务器,在收到加密文件后,解密文件。我卡在这里。
我在这里使用第一个回复加密了文件最简单的方法来加密java中的文本文件(使用DES)并将文件发送到服务器。服务器接收文件但它接收到加密(显然)。我读了一些关于 ssl 自动解密的信息,但我该如何设置呢?任何帮助将非常感激。
Server:
this.factory.setPort(port);
this.ssl.setKeystoreFile(this.getKeystore());
this.ssl.setKeystorePassword("password");
this.factory.setSslConfiguration(ssl.createSslConfiguration());
this.factory.setImplicitSsl(true);
this.serverFactory.addListener("default",
factory.createListener());
this.userManagerFactory.setFile(new File("user.properties"));
this.serverFactory.setUserManager
(userManagerFactory.createUserManager());
this.server = serverFactory.createServer();
this.server.start();
Client:
ftpsClient.connect(server,port);
ftpsClient.login(user,pass);
ftpsClient.enterLocalPassiveMode();
ftpsClient.type(FTP.BINARY_FILE_TYPE);
File firstLocalFile =encryptFile();
String firstRemoteFile = "test.txt";
InputStream is = new FileInputStream(firstLocalFile);
ftpsClient.storeFile(firstRemoteFile, is);
is.close();
ftpsClient.logout();
ftpsClient.disconnect();
解决方案
推荐阅读
- c++ - 如何使用 pybind11 和 cmake 链接 2 个模块
- python - 在 Python 2.7 和 3.6 的 biopython 中导入错误(“无法导入名称序列”)
- django - 如何创建具有循环和 null=False 关系的模型实例?
- vue.js - 未加载时调用路由组件方法
- android - 添加 com.android.support:design 导致无法解决 R 错误
- makefile - tr.dynamic:找不到命令“ginstall”的 tr.dynamic 策略
- java - 提取 XML 属性忽略命名空间
- angular - dotnet core + Angular Universal + docker => 由于错误,预渲染失败:错误:找不到模块
- c# - VSTO - 在异步 BackgroundWorker 运行时禁用 Excel
- azure-sql-database - 带有大表的 Azure SQL 数据库异地复制