「恺撒密码」据传是古罗马恺撒大帝用来保护重要军情的加密系统。
恺撒加密(Caesar cipher)是一种简单的消息编码方式:它根据字母表将消息中的每个字母移动常量位k。举个例子如果k等于3,则在编码后的消息中,每个字母都会向前移动3位:a会被替换为d;b会被替换成e;依此类推。字母表末尾将回卷到字母表开头。于是,w会被替换为z,x会被替换为a。
Our beloved Republic is in the hands of madmen. This is a dark day and I stand at a fork of the road. I can abide the law and surrender my arms to the senate and watch the Repubic fall to tyranny and chaos! Or, I can go home with my sword in my hand and run those maniacs to the Tarpeian Rock!
将这段演讲(《Rome》中Caesar反攻Pompey所作演讲)以key=13加密得到如下结果:
bhe orybirq erchoyvp vf va gur unaqf bs znqzra. guvf vf n qnex qnl naq v fgnaq ng n sbex bs gur ebnq. v pna novqr gur ynj naq fheeraqre zl nezf gb gur frangr naq jngpu gur erchovp snyy gb glenaal naq punbf! be, v pna tb ubzr jvgu zl fjbeq va zl unaq naq eha gubfr znavnpf gb gur gnecrvna ebpx!
恺撒加密法Python代码,恺撒加密法暴力破解(穷举)代码: