标签:... name make pen nbsp des 括号 crypto blocks
学习区块链之后,发现还要学习加密,接触到的视频是:Go的crypto包,所以开始接触Go。因为和solidity有些相似,但是比solidity简单一些,就开始放松的心态去学习。
每天翻着go菜鸟教程,感觉简单的一批,可是当自己真要写代码的时候,就有点闷了.
--凡是还是得脚踏实地才行!
package main import "fmt" func main() { //var type_name []type /* 切片:[]无参数 数组:只能修改值,无法改变长度,无法添加新元素 固定长度 [n] [...] //根据元素的个数来设置数组的大小 */ var e []byte //var e []byte = make([]byte,len) //e := make([]byte,len) //var a = [5]byte //type [5]byte is not an expression,= []byte{}一定要加大括号 var a [6]byte var b = [...]byte{0} var f byte = b[0] //var c [...]byte //use of [...] array outside of array literal //b = append(b, byte(1)) //first argument to append must be slice; have [0]byte fmt.Println(a, b, e, f) padding([]byte{1, 2, 3, 4, 4, 4, 4, 5}, 3) } //简单DES加密初识 func padding(src []byte, blockSize int) []byte { number := int(len(src)) % blockSize fmt.Println(blockSize) //e := blockSize d := make([]byte, blockSize) fmt.Println(d) var i int var newByte []byte //newByte = append(newByte, byte(0)) for i = 0; i < blockSize; i++ { //return newByte[i] = 0 newByte = append(newByte, byte(blockSize)) //fmt.Println(i) } fmt.Println(newByte) if number == 0 { //src = append(src, [blockSize]byte{0}) return src } fmt.Println(number) return src }
标签:... name make pen nbsp des 括号 crypto blocks
原文地址:https://www.cnblogs.com/eilinge/p/10134713.html