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)	
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章