1 Star 0 Fork 0

rocket049 / easySecurityLink

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README

简单安全连接:easySecurityLink

简单的意思,就是用法比TLS、SSL、SSH简单。

功能也比较单一,就是点对点加密连接,连接时自动生成临时密钥,不需要预先准备密钥。

需要注意的是,这种加密机制可以防止网络监听,但无法防止“中间人攻击”。

算法说明

连接时客户端生成一对2048位RSA密钥,然后把公钥发送到服务端,服务端随机生成一个256位AES密码,用接收到的RSA公钥加密此密码,发送给客户端,然后双方用此AES密码加密全部信息。

引用方法

import "github.com/rocket049/easySecurityLink"

用法简介

一、客户端

	c, err := easySecurityLink.Dial("host:port")
	if err != nil {
		panic(err)
	}
	defer c.Close()
	//...
	c.Write("type", []byte("message"))
	//...
	msg,err := c.Read()
	if err != nil {
		panic(err)
	}
	//...

二、服务端

用法一:

	l, err := net.Listen("tcp", "0.0.0.0:port")
	if err != nil {
		panic(err)
	}
	defer l.Close()
	for {
		c, err := easySecurityLink.Accept(l)
		if err != nil {
			panic(err)
		}
		defer c.Close()
		//使用c ...
	}

用法二:

	l, err := net.Listen("tcp", "0.0.0.0:port")
	if err != nil {
		panic(err)
	}
	defer l.Close()
	for {
		c, err := l.Accept()
		if err != nil {
			return err
		}
		defer c.Close()
		conn, err := easySecurityLink.Upgrade(c)
		if err != nil {
			return err
		}
		defer conn.Close()
		//使用conn ...
	}

具体用法可以参考examples

Empty file

About

简单安全连接:easySecurityLink。 简单的意思,就是用法比TLS、SSL、SSH简单。 expand collapse
Go
Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/rocket049/easySecurityLink.git
git@gitee.com:rocket049/easySecurityLink.git
rocket049
easySecurityLink
easySecurityLink
master

Search

344bd9b3 5694891 D2dac590 5694891