大体框架有了但是缺一些核心代码
刚刚接触go语言感觉还不太能读懂这个框架的意思
http://csintro.ucas.ac.cn/static/code_project/hide.go
主要是中间需要填写四个函数
第一个_4byte2int不太明白是什么作用,应该怎么写
后面有两个函数给了伪代码,
```
Procedure HideText (pixel_array) {
content = read all bytes of text file
length = length of the content
insert_data(length, pixel_array[0:16], 16)
for i = 0 to len(content)-1 {
v = content[i]
// the offset of pixel array
offset = 16+i*4
// the corresponding slice that will be used
insert_data(byte, pixel_array[offset: offset+4], 4)
}
}
// hide the integer data into the byte slice
// using the first n bytes of the slice
Procedure insert_data(data, byte_slice, n) {
for i = 0 to n-1 {
_2bit = data & 0x3
byte_slice[i] = byte_slice[i] & 0xFC
byte_slice[i] = byte_slice[i] | _2bit
data = data >> 2
}
}
Procedure ShowText (pixel_array) {
length = restore_data(pixel_array[0:16], 16)
content = create a byte slice with the specific length
for i = 0 to length-1 {
// the offset of pixel array
offset = 16+i*4
// the corresponding slice that will be translated to a byte
content[i] = restore_data(pixel_array[offset: offset+4], 4)
}
}
// restore the integer data from the byte slice
// using the first n bytes of the slice
Procedure restore_data(byte_slice, n) {
data = 0
for i = n-1 to 0 {
_2bit = byte_slice[i] & 0x3
data = data << 2
data = data | _2bit
}
}
```
对应的是后两个函数,但是伪代码里面调用函数时的变量类型都不同_(:зゝ∠)_然后就又不知道怎么下手了
更多评论