热爱互联网

小小的总结

6.16号学校发了双证,再也不是临时工了,哈哈。

前两个星期在折腾google的gyp构建系统,各种蛋疼后,发现不能解决我们现在的工程面临的环境配置问题,所以放弃了。
然后这几天上班一直在弄linux下的交叉编译环境,挺蛋疼的,各种不熟悉,
不过热情的同事帮忙解决了各种问题,搜噶,今天编译环境配好了。
智能摄像头挺好玩的,长姿态了。。过几天把程序放到摄像头芯片里面跑跑看:)

周末主要在解决学校的遗留问题,关于golang的。主要碰到两个问题,如下:

(1)

(注意:下面只测试了sqlite3数据库,其余数据库的情况不知道。)

平时向数据库中插入数据都是这样子的:

var id, msg string
db.Exec(“insert into data(id, msg) values(?, ?)”, id, msg)

一般情况下是没问题的,但是如果msg中包含了各种不可见字符,只要是一个byte
能表示的,都可能包含在msg中,那么用这种方法将导致msg不能插入到数据库中。
(golang中的byte是无符号的)

解决方法是这样插入:
db.Exec(“insert into data(id, msg) values(?, ?)”, id, []byte(msg))

(2)

AES加密算法,每次加密解密前都必须重新设置 iv (initialization vector, 初始化向量)。

blockMode := cipher.NewCBCEncrypter(block, iv)

记住,这是 CBC 的特点。

本来想在初始化时设置,这样可以优化很多性能,结果哥错了。

惨痛的教训。。

3 Comments

  • Posted 20/11/2016 at 10:15 | Permalink

    I don’t even know what to say, this made things so much eaisre!

  • Posted 23/11/2016 at 23:18 | Permalink

    Mark- I especially like the accepting feel. The unconditional love of a Mother in morning light. I have listened and prayed for that peace too. I don’t think truth is about my way or the highway. I like your style of thinking. I have found it be both challenging and engaging. Provocative but always creative. Progressive with roots in the classics. Maybe there’s a certain honesty and integrity in seeing that there is a lot of different kinds of good.

  • Posted 27/11/2016 at 22:42 | Permalink

    That’s a nicely made answer to a challenging question

Post a Comment

Your email is kept private. Required fields are marked *