2010-09-30
工具
昨日晚饭过后,我尝试了两个静态分析的开源工具:splint和cppcheck。前者适用于C代码,而后者主攻C++。此二软件用法很类似,使用起来相当简单,说明页解释也算详尽。也许功能不是十分强大,但作为一个额外的例行检查的工具,也未尝不是一个好主意。
桑拿
人们都说“秋高气爽”;一直以来我固执的认为用这个词来形容北半球9月底的天气应该不为过。
为了不在热浪来袭之时艰难骑行,早上七点不到,我就携自行车离开家门,踏上了骑车上学的路。谁知这一路下来,我仍感觉像是在体育馆的桑拿室里走了一遭,浑身感到无比的舒畅。
为了不在热浪来袭之时艰难骑行,早上七点不到,我就携自行车离开家门,踏上了骑车上学的路。谁知这一路下来,我仍感觉像是在体育馆的桑拿室里走了一遭,浑身感到无比的舒畅。
2010-09-26
酷热
本以为已是夏去秋来乌鹊南飞。谁知这两日又恢复了酷热难当的气候。窗外楼下的泳池里,整个下午都充斥了玩水游乐以及消暑的少年儿童,以及他们余音绕梁三日不绝的时而平缓时而尖锐的快乐的嬉戏之声。
在这炎热而喧嚣的环境里,头脑昏昏沉沉意欲午睡的我,躺在床上,浑身冒着热汗,翻来覆去难以入眠。
在这炎热而喧嚣的环境里,头脑昏昏沉沉意欲午睡的我,躺在床上,浑身冒着热汗,翻来覆去难以入眠。
2010-09-25
博物
今天是史密森尼协会的一年一度的博物馆日,借此东风,我和贝免费参观了位于巴尔博亚公园的航空航天博物馆和自然历史博物馆。
航空航天博物馆里展出了各个年代的飞行工具,其中有个展台也不出人意料地展出了飞虎队的一些资料。其美中不足的是展出的规模较小,和华盛顿特区的航空航天馆自然不能比较,甚至比西雅图的波音飞行博物馆都相去甚远。
自然历史博物馆有五层展厅,展出的物品大体可以概括为矿石、水源、骨架和绘画,均和自然地质相关。其中关于矿石的展厅还陈列了一幅慈禧太后的图画,以展示她对产出于当地的宝石之喜爱。
由于展品实在不多,这次游览全程历时只有不到三个小时。随后我们在公园里走马观花的看了一下一个盆栽展和一个“勿忘我花园”,最终耐不住炎热的天气,早早的打道回府。
航空航天博物馆里展出了各个年代的飞行工具,其中有个展台也不出人意料地展出了飞虎队的一些资料。其美中不足的是展出的规模较小,和华盛顿特区的航空航天馆自然不能比较,甚至比西雅图的波音飞行博物馆都相去甚远。
自然历史博物馆有五层展厅,展出的物品大体可以概括为矿石、水源、骨架和绘画,均和自然地质相关。其中关于矿石的展厅还陈列了一幅慈禧太后的图画,以展示她对产出于当地的宝石之喜爱。
由于展品实在不多,这次游览全程历时只有不到三个小时。随后我们在公园里走马观花的看了一下一个盆栽展和一个“勿忘我花园”,最终耐不住炎热的天气,早早的打道回府。
庆典
这周四括康迎来了开业25周年庆典盛况。
庆典的舞台就搭在我所在的办公楼旁边的一个停车场。
那天傍晚,会场里人群熙熙攘攘。
值此契机,括康博物馆也第一次正式开放。
尽管大会提供的食物有些令我们失望,
但是请来的乐队DMB据说还得过格莱美奖。
在欣赏了将近两个小时的据说令人激动人心的音乐之后,歌词没有听懂几句的我不知咋的感觉有些惆怅。
庆典的舞台就搭在我所在的办公楼旁边的一个停车场。
那天傍晚,会场里人群熙熙攘攘。
值此契机,括康博物馆也第一次正式开放。
尽管大会提供的食物有些令我们失望,
但是请来的乐队DMB据说还得过格莱美奖。
在欣赏了将近两个小时的据说令人激动人心的音乐之后,歌词没有听懂几句的我不知咋的感觉有些惆怅。
2010-09-22
中秋
一转眼,中秋节又到了。套用我妈在QQ空间上的一句话“祝福朋友们中秋节快乐天天都有好心情!”
因素
根据观察,影响自行车客骑行劳累程度的因素除了自行车客的体力、自行车客(连同车)的体重、骑行的坡度、沿途所遇交通灯的次数之外,自行车的胎压和心理作用也占据相当比例。
今日清晨,骑在有比昨日鼓了一倍的车胎的自行车上上学,我的双腿仿佛充满了力量,到达目的地时,也似乎没有平时劳累。
今日清晨,骑在有比昨日鼓了一倍的车胎的自行车上上学,我的双腿仿佛充满了力量,到达目的地时,也似乎没有平时劳累。
2010-09-21
合并
今天咱们的主题又是格式转换:讲的是如何合并若干个FLV文件到一个文件去。FLV是Flash Video格式。FLV文件的合并对于热衷于从土豆网上下载分段小电影的影迷尤其适用。
这次格式转换使用的工具`mencoder`,是mplayer的编码器。合并若干clip*.flv文件到一个video_full.flv文件可用的命令样本如下:
mencoder -forceidx -of lavf -oac copy -ovc copy -o video_full.flv clip01.flv, clip02.flv clip03.flv
这里'-forceidx'选项的作用是强制重建索引。根据说明书介绍,这个选项对于索引损坏的影音文件很有用途,它能够使得本来有困难的文件再次具备拖动搜寻功能。
'-of lavf'选项的作用是指定输出编码格式为lavf。根据说明书描述,'lavf'是FFmpeg libavformat muxers。
'-oac copy'的意思是对音频只进行流复制(streamcopy),不进行编码。
'-ovc copy'的意思于上面一条异曲同工,即对视频只进行流复制而不编码。
后来的选项就一目了然了:'-o'指定输出文件路径,紧接着是输入文件列表。
至此,咱们大功告成。
这次格式转换使用的工具`mencoder`,是mplayer的编码器。合并若干clip*.flv文件到一个video_full.flv文件可用的命令样本如下:
mencoder -forceidx -of lavf -oac copy -ovc copy -o video_full.flv clip01.flv, clip02.flv clip03.flv
这里'-forceidx'选项的作用是强制重建索引。根据说明书介绍,这个选项对于索引损坏的影音文件很有用途,它能够使得本来有困难的文件再次具备拖动搜寻功能。
'-of lavf'选项的作用是指定输出编码格式为lavf。根据说明书描述,'lavf'是FFmpeg libavformat muxers。
'-oac copy'的意思是对音频只进行流复制(streamcopy),不进行编码。
'-ovc copy'的意思于上面一条异曲同工,即对视频只进行流复制而不编码。
后来的选项就一目了然了:'-o'指定输出文件路径,紧接着是输入文件列表。
至此,咱们大功告成。
2010-09-19
避祸
话说今天下午,阳光明媚,万里无云。我和贝去家附近的购物广场游荡。这购物的过程可谓风平浪静,波澜不惊。我们在买了两件物品后兴尽而归。
从停车场开出,已经进入大路的我脚踏油门,准备加速。正在此时,一辆汽车从垂直的旁道突然窜出,意欲左转穿越。说时迟那时快,眼看一场车祸的惨剧就要发生,来不及考虑的我猛踩刹车。在轮胎摩擦地面而产生的一股青烟过后,两辆汽车都戛然而止。而此时两车保险杠之间的距离,应该不比十分之一英寸多许多。
目睹一起车祸就这样得以避免,我不由得在有些后怕的同时,长出了一口气。
从停车场开出,已经进入大路的我脚踏油门,准备加速。正在此时,一辆汽车从垂直的旁道突然窜出,意欲左转穿越。说时迟那时快,眼看一场车祸的惨剧就要发生,来不及考虑的我猛踩刹车。在轮胎摩擦地面而产生的一股青烟过后,两辆汽车都戛然而止。而此时两车保险杠之间的距离,应该不比十分之一英寸多许多。
目睹一起车祸就这样得以避免,我不由得在有些后怕的同时,长出了一口气。
2010-09-18
贪婪
根据《百度百科》,“贪婪”这个词语,拼音为tān lán,它的近义词为贪心,反义词为知足和满足等等。语义为求多,不知足,或者是多欲而不知满足,古文中左右皆恶之,以为贪而不知足(《战国策·齐策四》)等句子均是表示这个意思。
今天,我的一个Gmail帐号的所有容量都被用尽了。
[caption id="attachment_1101" align="alignleft" width="831" caption="gmail-warning-20100918"]
[/caption]
[caption id="attachment_1105" align="alignleft" width="776" caption="gmail-status-20100918"]
[/caption]
今天,我的一个Gmail帐号的所有容量都被用尽了。
[caption id="attachment_1101" align="alignleft" width="831" caption="gmail-warning-20100918"]
[caption id="attachment_1105" align="alignleft" width="776" caption="gmail-status-20100918"]
2010-09-15
转换
细心的读者也许还依稀记得,几个月前我搞到了一台Kindle DX。从那时开始,我阅读书籍的数量开始有所增加——尽管其中多数是娱乐图书诸如古龙小说和郑渊洁童话。而我在Kindle DX上存放的书,99%以上都是PDF格式。Kindle DX还是不错的产品,但我遭遇的唯一问题是,它无法正确显示文字版的中文书籍。对此我的解决方案是把文字版的图书转换为图片格式,而使用的工具是ImageMagick中的`convert`工具。由于在Linux上它的安装配置简单明了,咱们就用Windows做例子。
从ImageMagick的站点下载工具并安装。由于`convert`工具需要调用`gswin32c.exe`,咱们也需要安装它。一个简单的办法是安装AFPL Ghostscript,并把安装目录下的'bin'目录加入系统路径。此时基本任务完成,只需在命令行下输入
convert input.pdf output.jpg (也可以根据需要加入别的选项,譬如-density)
咱们就可以得到诸如output-1.jpg, output-2.jpg ...的图像文件。待转换完成,再将这些图片整合并入一个pdf文件
convert `ls *.jpg | sort -k1.8n` output.pdf
这样咱们就可以在Kindle上阅读outpt.pdf啦!
后记:由于convert在格式转换过程中是将结果写入内存然后一并输出到磁盘,如果被处理的文件页数太多,也许会出现内存不足的错误。一个解决方案是逐页输出。譬如,在Windows命令行下处理一个1000页的pdf
for /L %i in (0,1,999) do @(convert -density 400 input.pdf[%i] -scale 992x1403 output%d.jpg)
这里'-density 400'意味着以400dpi读入pdf,'-scale 992x1483'设置输出尺寸为A4 (120dpi).
从ImageMagick的站点下载工具并安装。由于`convert`工具需要调用`gswin32c.exe`,咱们也需要安装它。一个简单的办法是安装AFPL Ghostscript,并把安装目录下的'bin'目录加入系统路径。此时基本任务完成,只需在命令行下输入
convert input.pdf output.jpg (也可以根据需要加入别的选项,譬如-density)
咱们就可以得到诸如output-1.jpg, output-2.jpg ...的图像文件。待转换完成,再将这些图片整合并入一个pdf文件
convert `ls *.jpg | sort -k1.8n` output.pdf
这样咱们就可以在Kindle上阅读outpt.pdf啦!
后记:由于convert在格式转换过程中是将结果写入内存然后一并输出到磁盘,如果被处理的文件页数太多,也许会出现内存不足的错误。一个解决方案是逐页输出。譬如,在Windows命令行下处理一个1000页的pdf
for /L %i in (0,1,999) do @(convert -density 400 input.pdf[%i] -scale 992x1403 output%d.jpg)
这里'-density 400'意味着以400dpi读入pdf,'-scale 992x1483'设置输出尺寸为A4 (120dpi).
粘贴
尊贵的读者们(可以用“们”字吗?),请允许我交叉粘贴一份GPG教程,以备不时之需。
http://syncom.appspot.com/papers/pgptutorial.txt
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% A Step-by-step Guide for PGP Beginners %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Released by Phil Zimmermann in 1991, Pretty Good Privacy (PGP) is a computer
program that supports encryption and digital signing of files. PGP is used
by many to secure e-mail communications. PGP is free for personal use, but
not open source software. In this guide, we will walk you walk you through
the basic, and thus perhaps most important, use cases of an open source
alternative to PGP, GNU Privacy Guard (GnuPG, or gpg). Specifically, we will
show
* How to create signing and encryption keys
* How to export and import GPG keys
* How to uses keys to sign and encrypt files
* How to submit keys to public key servers
* Concepts of "web of trust" and "PGP key signing party"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0. GnuPG
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GnuPG is a shell-based tool that comes with many of the prevailing Linux
distributions such as Debian, Fedora, Ubuntu. Like PGP, GnuPG implements
the OpenPGP standard (RFC4880, http://tools.ietf.org/html/rfc4880).
Although multiple graphic user interfaces are available for GnuPG, throughout
this tutorial, we will perform operations using GnuPG version 1.4.9 from a
shell prompt, starting with '$'.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1. Creation of Signing and Encryption Keys
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Enter
$ gpg --cert-digest-algo=SHA256 --gen-key
and you will see the following prompt screen
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Please select what kind of key you want:
(1) DSA and Elgamal (default)
(2) DSA (sign only)
(5) RSA (sign only)
Your selection?
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DSA keypair will have 1024 bits.
ELG-E keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048)
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Requested keysize is 2048 bits
Please specify how long the key should be valid.
0 = key does not expire
= key expires in n days
w = key expires in n weeks
m = key expires in n months
y = key expires in n years
Key is valid for? (0)
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
"Heinrich Heine (Der Dichter) "
Real name: Ning Shang
Email address: test_id@example.com
Comment: GPG Demonstration
You selected this USER-ID:
"Ning Shang (GPG Demonstration) "
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit?
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Enter passphrase:
Repeat passphrase:
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
blah blah blah...
gpg: key 396AE107 marked as ultimately trusted
public and secret key created and signed.
pub 1024D/396AE107 2010-01-20
Key fingerprint = 3798 37EB 0C2F 2B93 C293 81BE 2BF7 E43D 396A E107
uid Ning Shang (GPG Demonstration)
sub 2048g/F904BF81 2010-01-20
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
pub 1024D/396AE107 2010-01-20
uid Ning Shang (GPG Demonstration)
sub 2048g/F904BF81 2010-01-20
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
sec 1024D/396AE107 2010-01-20
uid Ning Shang (GPG Demonstration)
ssb 2048g/F904BF81 2010-01-20
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< plaintext.txt
To encrypt "plaintext.txt" into an ASCII-armored cipher text file,
$ gpg --encrypt -a --output ciphertext.txt plaintext.txt
Enter the email address "test_id@example.com" of the recipient, yourself
in this case
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
You did not specify a user ID. (you may use "-r")
Current recipients:
Enter the user ID. End with an empty line: test_id@example.com
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
gpg: there is a secret key for public key "396AE107"!
gpg: use option "--delete-secret-keys" to delete it first.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
As indicated in the error message, the command to delete a private key from your
secret keyring is
$ gpg --delete-secret-key $KEYID
You will then be asked twice to confirm this operation. Once a private key is
delete from your secret keying, you will not be able to use it to sign or
decrypt messages.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4. Submitting public key to a key server
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A convenient way to publish and manage your public keys is to use a PGP key
server. "pgp.mit.edu" is a PGP key server that is publicly available. To
send your public key to a key server, do
$ KEYSERVER=pgp.mit.edu
$ gpg --keyserver $KEYSERVER --send-keys $KEYID
People now can get access to your public key through this key server. Several
other public PGP key servers are
http://www.keyserver.net
http://wwwkeys.pgp.net
http://keyserver.ubuntu.com
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5. "Web of trust"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The concept of "web of trust" is a means adopted by OpenPGP-compatible systems
to establish a binding between a user's identity credentials (name, email, etc)
and her public key. Unlike the hierarchical trust model of a public key
infrastructure, the web of trust can be visualized as a directed graph, in which
a directed edge connects the source and destination of a trust relationship.
There exist four trust levels in a PGP web of trust:
- unknown
Nothing is known about the owner's judgment in key signing. Keys on your
public keyring that you do not own initially have this trust level.
- none
The owner is known to improperly sign other keys.
- marginal
The owner understands the implications of key signing and properly
validates keys before signing them.
- full
The owner has an excellent understanding of key signing, and his signature
on a key would be as good as your own.
The GPG command line tool allows one to assign and adjust one's trust in a key's
owner. Interested readers may refer to Section 4 of [5] for more details.
The rules used by the web of trust to validate keys is the following:
A key K is considered valid if it meets two conditions:
1. it is signed by enough valid keys, meaning
- you have signed it personally,
- it has been signed by one fully trusted key, or
- it has been signed by three marginally trusted keys;
and
2.
- the path of signed keys leading from K back to your own key is five steps or
shorter.
A way to actively get involved into the web of trust is to have your key signed
by others or sign (your trusted) others keys. As it may directly affect, at
least locally, the web of trust, signing a key is a relatively big
responsibility, and hence should be executed with care. The xkcd.com column
in [6] illustrates the severity of improperly signing another person's public
key.
One way to sign a key or have your key signed is through a "key signing party",
for which strict rules are to be followed. You can read more about a key
signing party in [3].
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6. References
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[1] GnuPG manpage.
[2] "Personal encryption." Linux Format Magazine 21, December 2001, pages
32-33.
[3]. "The Key Signing Party - How to".
http://www.cryptnet.net/fdp/crypto/keysigning_party/en/keysigning_party.html
[4] GnuPrivacyGuardHowto.
https://help.ubuntu.com/community/GnuPrivacyGuardHowto
[5] "The GNU Privacy Handbook." http://www.gnupg.org/gph/en/manual.html
[6] "Responsible behavior". http://xkcd.com/364/
http://syncom.appspot.com/papers/pgptutorial.txt
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% A Step-by-step Guide for PGP Beginners %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Released by Phil Zimmermann in 1991, Pretty Good Privacy (PGP) is a computer
program that supports encryption and digital signing of files. PGP is used
by many to secure e-mail communications. PGP is free for personal use, but
not open source software. In this guide, we will walk you walk you through
the basic, and thus perhaps most important, use cases of an open source
alternative to PGP, GNU Privacy Guard (GnuPG, or gpg). Specifically, we will
show
* How to create signing and encryption keys
* How to export and import GPG keys
* How to uses keys to sign and encrypt files
* How to submit keys to public key servers
* Concepts of "web of trust" and "PGP key signing party"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0. GnuPG
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GnuPG is a shell-based tool that comes with many of the prevailing Linux
distributions such as Debian, Fedora, Ubuntu. Like PGP, GnuPG implements
the OpenPGP standard (RFC4880, http://tools.ietf.org/html/rfc4880).
Although multiple graphic user interfaces are available for GnuPG, throughout
this tutorial, we will perform operations using GnuPG version 1.4.9 from a
shell prompt, starting with '$'.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1. Creation of Signing and Encryption Keys
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Enter
$ gpg --cert-digest-algo=SHA256 --gen-key
and you will see the following prompt screen
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Please select what kind of key you want:
(1) DSA and Elgamal (default)
(2) DSA (sign only)
(5) RSA (sign only)
Your selection?
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DSA keypair will have 1024 bits.
ELG-E keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048)
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Requested keysize is 2048 bits
Please specify how long the key should be valid.
0 = key does not expire
= key expires in n days
w = key expires in n weeks
m = key expires in n months
y = key expires in n years
Key is valid for? (0)
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
"Heinrich Heine (Der Dichter) "
Real name: Ning Shang
Email address: test_id@example.com
Comment: GPG Demonstration
You selected this USER-ID:
"Ning Shang (GPG Demonstration) "
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit?
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Enter passphrase:
Repeat passphrase:
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
blah blah blah...
gpg: key 396AE107 marked as ultimately trusted
public and secret key created and signed.
pub 1024D/396AE107 2010-01-20
Key fingerprint = 3798 37EB 0C2F 2B93 C293 81BE 2BF7 E43D 396A E107
uid Ning Shang (GPG Demonstration)
sub 2048g/F904BF81 2010-01-20
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
pub 1024D/396AE107 2010-01-20
uid Ning Shang (GPG Demonstration)
sub 2048g/F904BF81 2010-01-20
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
sec 1024D/396AE107 2010-01-20
uid Ning Shang (GPG Demonstration)
ssb 2048g/F904BF81 2010-01-20
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< plaintext.txt
To encrypt "plaintext.txt" into an ASCII-armored cipher text file,
$ gpg --encrypt -a --output ciphertext.txt plaintext.txt
Enter the email address "test_id@example.com" of the recipient, yourself
in this case
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
You did not specify a user ID. (you may use "-r")
Current recipients:
Enter the user ID. End with an empty line: test_id@example.com
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
gpg: there is a secret key for public key "396AE107"!
gpg: use option "--delete-secret-keys" to delete it first.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
As indicated in the error message, the command to delete a private key from your
secret keyring is
$ gpg --delete-secret-key $KEYID
You will then be asked twice to confirm this operation. Once a private key is
delete from your secret keying, you will not be able to use it to sign or
decrypt messages.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4. Submitting public key to a key server
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A convenient way to publish and manage your public keys is to use a PGP key
server. "pgp.mit.edu" is a PGP key server that is publicly available. To
send your public key to a key server, do
$ KEYSERVER=pgp.mit.edu
$ gpg --keyserver $KEYSERVER --send-keys $KEYID
People now can get access to your public key through this key server. Several
other public PGP key servers are
http://www.keyserver.net
http://wwwkeys.pgp.net
http://keyserver.ubuntu.com
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5. "Web of trust"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The concept of "web of trust" is a means adopted by OpenPGP-compatible systems
to establish a binding between a user's identity credentials (name, email, etc)
and her public key. Unlike the hierarchical trust model of a public key
infrastructure, the web of trust can be visualized as a directed graph, in which
a directed edge connects the source and destination of a trust relationship.
There exist four trust levels in a PGP web of trust:
- unknown
Nothing is known about the owner's judgment in key signing. Keys on your
public keyring that you do not own initially have this trust level.
- none
The owner is known to improperly sign other keys.
- marginal
The owner understands the implications of key signing and properly
validates keys before signing them.
- full
The owner has an excellent understanding of key signing, and his signature
on a key would be as good as your own.
The GPG command line tool allows one to assign and adjust one's trust in a key's
owner. Interested readers may refer to Section 4 of [5] for more details.
The rules used by the web of trust to validate keys is the following:
A key K is considered valid if it meets two conditions:
1. it is signed by enough valid keys, meaning
- you have signed it personally,
- it has been signed by one fully trusted key, or
- it has been signed by three marginally trusted keys;
and
2.
- the path of signed keys leading from K back to your own key is five steps or
shorter.
A way to actively get involved into the web of trust is to have your key signed
by others or sign (your trusted) others keys. As it may directly affect, at
least locally, the web of trust, signing a key is a relatively big
responsibility, and hence should be executed with care. The xkcd.com column
in [6] illustrates the severity of improperly signing another person's public
key.
One way to sign a key or have your key signed is through a "key signing party",
for which strict rules are to be followed. You can read more about a key
signing party in [3].
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6. References
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[1] GnuPG manpage.
[2] "Personal encryption." Linux Format Magazine 21, December 2001, pages
32-33.
[3]. "The Key Signing Party - How to".
http://www.cryptnet.net/fdp/crypto/keysigning_party/en/keysigning_party.html
[4] GnuPrivacyGuardHowto.
https://help.ubuntu.com/community/GnuPrivacyGuardHowto
[5] "The GNU Privacy Handbook." http://www.gnupg.org/gph/en/manual.html
[6] "Responsible behavior". http://xkcd.com/364/
阴天
今天是个难得的阴天,可能还下了点儿小雨。这一点我还躺在床上时就已经知道,因为我曾经受伤的踝部开始隐隐作痛。
这可谓一个绝佳的骑车上学的好天气。气喘吁吁的我在经历了最后一个大上坡到达目的地之后,想到这学期已经从事了这么多次的骑车上学练习却仍不能如鱼得岁挥洒自如不费吹灰之力地驾驭这坐骑以及肥胖的身躯的无奈事实,不禁开始感慨青春的逝去。
这可谓一个绝佳的骑车上学的好天气。气喘吁吁的我在经历了最后一个大上坡到达目的地之后,想到这学期已经从事了这么多次的骑车上学练习却仍不能如鱼得岁挥洒自如不费吹灰之力地驾驭这坐骑以及肥胖的身躯的无奈事实,不禁开始感慨青春的逝去。
2010-09-12
周日
常言道“时光似箭,日月如梭”。我觉得说得真不错。一眨眼,一周又这么不经意地过去了。
今天又是个周日。早上8点不到就醒来的我,在一场回笼大觉之后起床时,已经是接近正午了。
而在午饭后和晚饭前的下午,除了在期盼美网决赛之中得到其延期消息的同时完成了一篇论文的评论,我几乎什么都没有做。想到周一就又要来临,我不禁有些沮丧。
今天又是个周日。早上8点不到就醒来的我,在一场回笼大觉之后起床时,已经是接近正午了。
而在午饭后和晚饭前的下午,除了在期盼美网决赛之中得到其延期消息的同时完成了一篇论文的评论,我几乎什么都没有做。想到周一就又要来临,我不禁有些沮丧。
2010-09-09
小雨
古语有云“渭城朝雨浥轻尘,客舍青青柳色新”。今日的圣亚清晨,迎来了近几个月以来最大的一次小雨:证据是部分地面是湿漉漉的,同时伴有雨后特有的泥土气息。
在潮湿的马路上,被六点三十的闹钟叫醒的六点四十五起床的我,在七点刚过就推车出门,为了赶一个八点半的场,不那么风驰电掣地、气喘吁吁地快速骑行。
在潮湿的马路上,被六点三十的闹钟叫醒的六点四十五起床的我,在七点刚过就推车出门,为了赶一个八点半的场,不那么风驰电掣地、气喘吁吁地快速骑行。
2010-09-07
散步
圣亚初秋的晚间,凉风习习。身着背心长裤的我,在家附近的小区的饭后二十分钟的缓慢踱行之后,居然已是满头大汗。
2010-09-06
劳动
今天是劳动节假期。白天本应劳动的我,在平均历时三个小时的断断续续的三段餐后睡眠之后,在下午6时许,再次迎来了日薄西山。
“这一天又这么过去了。”精神有所抖擞的我自言自语如是道。
“这一天又这么过去了。”精神有所抖擞的我自言自语如是道。
2010-09-05
周日
尽管今天是个周日,但我还是决定骑҉车҉上҉学҉。平时拥挤的街道上,如今显得如此冷冷清。在我波澜不惊地闯了几个红灯之后,我那昨日扭伤的肥硕腰肢,正在开始隐隐作痛。
2010-09-04
备份
This is how I uploaded my email in Outlook to Gmail.
The OS used for demonstration in following tutorial is Windows 7.
In general, there are two steps:
1. Convert email to mbox format.
2. Use "IMAP Upload" python tool to upload local mbox files to IMAP4 server (Gmail in this case).
##########################################
# 1. Convert Outlook Email to mbox files with
# Mozilla Thunderbird
##########################################
Download Mozilla Thunderbird from its official website http://www.mozillamessaging.com/en-US/thunderbird/ and install it. The version of Thunderbird used in this tutorial is Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2.
Choose menu "Tools>Import" and use the "import" tool to import email from Outlook. Upon prompt "Import Everything or select the type of material to import:", I chose "Mail", since I was only interested in email. Once the importing finishes, you can see a "Outlook Import" folder under "Local Folders" in Thunderbird.
The imported email from Outlook is stored in mbox formatted files, in directory
C:\Users\\AppData\Roaming\Thunderbird\Profiles\.default\Mail\Local Folders\Outlook Import.sbd\Mailbox - XXXXXXX.sbd.
Under this directory, files of interests are
* Inbox
* Sent Items
and so on.
Copy this files to a separate directory , and rename them to .backup.mbox.
##########################################
# 2. Upload mbox Files to Gmail with "IMAP
# Upload"
##########################################
Download "IMAP Upload" from http://imap-upload.sourceforge.net/ and read the instructions. The version of "IMAP Upload" used for demonstration is v1.2, which requires Python 2.5 or later to run.
Unzip "IMAP Upload" to any directory, which we call in the text that follows. Move as a subdirectory of . CD into .
Execute the following commands to upload the mbox files to Gmail. Note that you need to ensure the existence of the corresponding labels (e.g. "Sent Items") in Gmail before the commands can return correctly; create corresponding "labels" in Gmail if they do not exist.
python imap_upload.py --gmail --box "Inbox" --error Inbox.err "./Inbox.backup..mbox"
python imap_upload.py --gmail --box "Sent Items" --error Sent.err "./Sent Items.backup..mbox"
If there are other mbox files you are interested in, perform similar steps for them. Upon the prompt for user name and password, enter your Gmail credentials, with "@gmail.com" omitted from user name.
Perform backup on updated mbox files from time to time. "IMAP Upload" will take care of the duplicated email and will not upload duplicated items.
The OS used for demonstration in following tutorial is Windows 7.
In general, there are two steps:
1. Convert email to mbox format.
2. Use "IMAP Upload" python tool to upload local mbox files to IMAP4 server (Gmail in this case).
##########################################
# 1. Convert Outlook Email to mbox files with
# Mozilla Thunderbird
##########################################
Download Mozilla Thunderbird from its official website http://www.mozillamessaging.com/en-US/thunderbird/ and install it. The version of Thunderbird used in this tutorial is Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2.
Choose menu "Tools>Import" and use the "import" tool to import email from Outlook. Upon prompt "Import Everything or select the type of material to import:", I chose "Mail", since I was only interested in email. Once the importing finishes, you can see a "Outlook Import" folder under "Local Folders" in Thunderbird.
The imported email from Outlook is stored in mbox formatted files, in directory
C:\Users\\AppData\Roaming\Thunderbird\Profiles\.default\Mail\Local Folders\Outlook Import.sbd\Mailbox - XXXXXXX.sbd.
Under this directory, files of interests are
* Inbox
* Sent Items
and so on.
Copy this files to a separate directory , and rename them to .backup.mbox.
##########################################
# 2. Upload mbox Files to Gmail with "IMAP
# Upload"
##########################################
Download "IMAP Upload" from http://imap-upload.sourceforge.net/ and read the instructions. The version of "IMAP Upload" used for demonstration is v1.2, which requires Python 2.5 or later to run.
Unzip "IMAP Upload" to any directory, which we call in the text that follows. Move as a subdirectory of . CD into .
Execute the following commands to upload the mbox files to Gmail. Note that you need to ensure the existence of the corresponding labels (e.g. "Sent Items") in Gmail before the commands can return correctly; create corresponding "labels" in Gmail if they do not exist.
python imap_upload.py --gmail --box "Inbox" --error Inbox.err "./Inbox.backup..mbox"
python imap_upload.py --gmail --box "Sent Items" --error Sent.err "./Sent Items.backup..mbox"
If there are other mbox files you are interested in, perform similar steps for them. Upon the prompt for user name and password, enter your Gmail credentials, with "@gmail.com" omitted from user name.
Perform backup on updated mbox files from time to time. "IMAP Upload" will take care of the duplicated email and will not upload duplicated items.
Subscribe to:
Posts (Atom)