bo和js

package main 
 
import (
	"encryp"
	"crypto/sha256"
	 "fmt"  
)
 
 
type sgTure struct{
	info []byte   //数字信息(加密)
	sginfo []byte //签名信息 
	randKey string //对称加密的密钥,随机生成
}
 
func main() {
	//发送的信息,Bob,你欠我的500元钱不用还了
	info:="hello,Bob,don't still owe me 500 yuan money"
	
	//将信息生成信息摘要
	data := []byte(info)
	sat:=sha256.Sum256(data)
	
	//用私钥对摘要进行加密,生成数字签名
	sginfo:=encryp.RsaEncrypt(sat)
	
	//将明文信息用随机密钥进行加密
	randkey=getRandStr()
	info:=encryp.EncryptDES(data,randkey)
	
	//以上信息打包发送给Bob
	sgture:=sgTure{
		info,
		sginfo:sginfo,
		randKey:randkey
	}
	
	sendToBob(sgture)	
}
package main 
 
import (
	"encryp"
	"crypto/sha256"
	 "fmt"  
)
 
 
type sgTure struct{
	info []byte   //数字信息(加密)
	sginfo []byte //签名信息 
	randKey string //对称加密的密钥,随机生成
}
 
func main() {
	//发送的信息,Bob,你欠我的500元钱不用还了
	info:="hello,Bob,don't still owe me 500 yuan money"
	
	//将信息生成信息摘要
	data := []byte(info)
	sat:=sha256.Sum256(data)
	
	//用私钥对摘要进行加密,生成数字签名
	sginfo:=encryp.RsaEncrypt(sat)
	
	//将明文信息用随机密钥进行加密
	randkey=getRandStr()
	info:=encryp.EncryptDES(data,randkey)
	
	//以上信息打包发送给Bob
	sgture:=sgTure{
		info,
		sginfo:sginfo,
		randKey:randkey
	}
	
	sendToBob(sgture)	
}

猜你喜欢

转载自blog.csdn.net/boss2967/article/details/103783318