我正在加密服务器和客户端之间的TCP连接.在研究和测试过程中,我倾向于使用密钥加密.我的问题是我找不到任何有关如何实现此功能的教程.我发现的教程围绕一次性https请求,我只需要一个SSL Socket.
我到目前为止编写的代码如下.我几乎可以肯定它需要扩展,我只是不知道如何.任何帮助表示赞赏.
private ServerSocketFactory factory;
private SSLServerSocket serverSocket;
factory = SSLServerSocketFactory.getDefault();
serverSocket = (SSLServerSocket) factory.createServerSocket( <portNum> );
Run Code Online (Sandbox Code Playgroud)
用于接受客户端连接的服务器代码
SSLSocket socket = (SSLSocket) serverSocket.accept();
socket.startHandshake();
Run Code Online (Sandbox Code Playgroud)
我只是不知道如何实际握手.
参考:http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html
我开发了一个aco算法.我认为它不能正常工作......很难解释,但我会尝试.
问题是信息素水平浮动.我认为,最佳路径上的信息素水平必须越来越高,但在我的程序中它并非如此.
Optimal path 是一个路径,通过在起始顶点和目标顶点之间的边缘上找到最大信息素水平来构建.
例:
1 5 3
4 5 10
0 0 0
Run Code Online (Sandbox Code Playgroud)
Optimal path会的1 -> 2 -> 3.
重量矩阵:
0 3 10
0 0 3
0 0 0
Run Code Online (Sandbox Code Playgroud)
最佳路径是:1 -> 2 -> 3 (length: 6)
另一条路径(非最佳路径):1 -> 3 (length: 10)
10只蚂蚁后的信息素水平:
0 5 1
0 0 3
0 0 0
Run Code Online (Sandbox Code Playgroud)
最佳路径: 1 -> 2 -> 3
20只蚂蚁后的信息素水平(10多个):
0 1 5
0 0 1
0 0 0
Run Code Online (Sandbox Code Playgroud)
最佳路径: 1 -> 3
30只蚂蚁后的信息素水平:
0 …Run Code Online (Sandbox Code Playgroud) 我正在将SceneBuilder与Netbeans的JavaFX库结合使用.我使用Scenebuilder为控制器类创建fxml和netbeans.目标是构建一个相当复杂的应用程序.
我可以启动一个JavaFX应用程序并连接控制器类就好了.但是,当我尝试打开一个新窗口时,我似乎无法将控制器类绑定到新窗口.为了简单起见,我希望新窗口有一个单独的控制器类,因为后端很复杂.
TL; DR - 尝试使用控制器类在JavaFX应用程序上打开一个新窗口.控制器类没有绑定.
代码示例如下
模型类 - 用于启动应用程序的包装器
public class Model extends Application{
public static void main(String[] args){
Application.launch(Model.class, args);
}
@Override
public void start(Stage stage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("Sample.fxml"));
stage.setScene(new Scene(root));
stage.show();
}
}
Run Code Online (Sandbox Code Playgroud)
Sample.fxml - 主应用程序的fxml文件
Sample.java - extends Initializable,是Sample.fxml的控制器类.下面是我尝试打开标题为"ServerConfigChooser"的新窗口的代码片段
try{
Parent root = FXMLLoader.load(getClass().getResource("ServerConfigChooser.fxml"));
FXMLLoader loader = new FXMLLoader(getClass().getResource("ServerConfigChooser.fxml"));
ServerConfigChooser controller = new ServerConfigChooser();
loader.setController(controller);
loader.setRoot(root);
Stage stage = new Stage();
stage.setScene(new Scene(root));
stage.show();
} catch (IOException ex)
Run Code Online (Sandbox Code Playgroud)
ServerConfigChooser.java - 实现Initializable
这就是我遇到问题的地方.我不能简单地使用与.fxml文件中的变量相同的fxid声明变量.调用类时,不会触发initialize()方法.
ServerConfigChooser类中构造函数的原因是我无法自动触发initialize()方法.我在构造函数中手动触发. …
我有两个String类型的arraylists,一个操作数和一个操作符
ArrayList<String> operands = new ArrayList<String>();
ArrayList<String> operators = new ArrayList<String>();
Run Code Online (Sandbox Code Playgroud)
它们就像这样填充
operands = { "\"symbol\": \"CHKP%\"", "\"price\": {$gt: 23.72\" };
operators = { "and"};
Run Code Online (Sandbox Code Playgroud)
理想情况下,我会将其转换为一个像这样填充的ArrayList
ArrayList<String> polishNotation = { "and",
"\"symbol\": \"CHKP%\"",
"\"price\": {$gt: 23.72\" };
Run Code Online (Sandbox Code Playgroud)
将波兰表示法硬编码为三个元素很容易,但我有不同数量的运算符和操作数(最多四个操作数和三个运算符).此代码用于将SQL select语句转换为MongoDB.find()语句.任何关于如何以波兰表示法(前缀波兰表示法)实现ArrayList合并的指针都将非常感激.
[编辑2]下面是一个带有3个运算符("like","和","<")和三个操作数('FLIR%',"price","price")的SQL语句的示例,它与MongoDB等效.我认为使用波兰表示法可以帮助我将SQL的查询顺序转换为Mongo排序的查询
在SQL中
SELECT * FROM STOCK WHERE symbol like 'FLIR%' and price > 24.04 and price < 24.39;
Run Code Online (Sandbox Code Playgroud)
在MongoDB中
db.STOCK.find({
"symbol": "FLIR%",
"price": {
"$gt": 24.04,
"$lt": 24.39
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个项目,我们每隔5分钟就会向文件中写入少量数据.我们的想法是查看这些数据在数小时,数天和数周内的变化情况.
其中一个要求是以安全格式存储此数据.我们已经有了一种加密方案,可以通过DataI/O流将这些数据作为byte []数组通过网络发送.
我的问题是,有没有办法将加密的byte []数组写入文本文件,以便我可以将它们读出来?我目前最大的问题是我正在从文件中读取字符串,这会弄乱byte []数组.
关于去哪里的任何想法或指示?
简而言之,我正在测试一个Google驱动器表单,该表单将记录学校选举的投票,以确保它是安全的.
有没有办法从共享URL和列表/输入数据中打开表单?简而言之,我是否可以编写一个脚本来表现得像投票机并试图破坏表单?
security penetration-testing google-apps-script google-forms
我是正则表达式的新手。
我需要编写符合以下条件的正则表达式
我写了以下表达式,但它不起作用
^[a-zA-Z\\d*]{8,20}$
Run Code Online (Sandbox Code Playgroud) 问题已解决!!!!!! 非常感谢trashgod和HoverCraftFullOfEels!我终于通过使用下面的例子并略微改变它来获得这个概念.更改允许缩放进度条(默认为100个单位).再次感谢您的耐心和愿意为此而努力.意味着很多人,~Kyte
ps - + 1全部'围绕:)
/** @see http://stackoverflow.com/questions/4637215 */
public class Threading_01 extends JFrame {
private static final String s = "0.00";
private JProgressBar progressBar = new JProgressBar(0, 100);
private JLabel label = new JLabel(s, JLabel.CENTER);
public Threading_01() {
this.setLayout(new GridLayout(0, 1));
this.setTitle("?2");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.add(progressBar);
this.add(label);
this.setSize(161, 100);
this.setLocationRelativeTo(null);
this.setVisible(true);
}
public void runCalc() {
// progressBar.setIndeterminate(true);
TwoWorker task = new TwoWorker();
task.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent e) {
if ("progress".equals(e.getPropertyName())) {
progressBar.setIndeterminate(false);
progressBar.setValue((Integer) e.getNewValue());
System.out.println("**: " …Run Code Online (Sandbox Code Playgroud) 我需要创建一些源代码文本文件的第一页的图像,例如asp或php或js文件.
我通常通过键入命令来完成此操作
enscript --no-header --pages=1 "${input_file}" -o - | ps2pdf - "${temp_pdf_file}"
convert -quality 100 -density 150x150 -append "${temp_pdf_file}"[0] "${output_file}"
trash "${temp_pdf_file}"
Run Code Online (Sandbox Code Playgroud)
这很适合我的需求,但它显然会"按原样"输出一个没有"眼睛糖果"功能的图像.我想知道是否有办法添加语法高亮.例如,这可能会加速创建已开发作品的演示文稿.
java ×6
algorithm ×1
ant-colony ×1
arraylist ×1
bash ×1
encryption ×1
file ×1
fxml ×1
google-forms ×1
javafx-2 ×1
jprogressbar ×1
mongodb ×1
netbeans ×1
regex ×1
scenebuilder ×1
security ×1
sockets ×1
ssl ×1
swing ×1
swingworker ×1