HDU4144:Bacon's Cipher
As we all know, each letter has its position in the alphabet, ‘A’ is 0, ‘B’ is 1, ‘C’ is 2…and so on. And each number can be represented in binary code, for example, 2 is ‘10’ in binary system. Then we expand the binary code to five digits by adding leading zeros, then 10 becomes 00010. Now we can use this number to encode. To simplify the question, we define the rules as below:
0 corresponds to a random uppercase letter and 1 corresponds to a random number, so after encoding, 00010 ( ‘C’ ) is transformed to ABC1D or JUG9N.
To decode, do the opposite way around.
ON1E2H5Q39AK2TGIC9ERT39B2P423L8B20D
题意:给出一串密码,字母代表0,数字代表1,每五个构成一个二进制,该二进制的值代表一个字母,求出明文
思路:水题,最近忙于考试,先A道水题来找找感觉
#include <stdio.h>
#include <string.h> int num(char c)
{
if(c>='A' && c<='Z')
return 0;
else return 1;
} int main()
{
int n,i,k;
char a[10005];
while(~scanf("%d%s",&n,a))
{
for(i = 0;i<n;i+=5)
{
k = 0;
if(num(a[i]))
k+=16;
if(num(a[i+1]))
k+=8;
if(num(a[i+2]))
k+=4;
if(num(a[i+3]))
k+=2;
if(num(a[i+4]))
k++;
printf("%c",k+'A');
}
printf("\n");
} return 0;
}
HDU4144:Bacon's Cipher的更多相关文章
- Bacon's Cipher(培根密码)
Description Bacon's cipher or the Baconian cipher is a method of steganography (a method of hiding a ...
- Encryption and decryption、Steganography、Decryption Tools
catalogue . 隐写术 . Substitution cipher . Transposition cipher . Bacon's cipher . LSB-Steganography 1. ...
- php crc32,md5,sha1,mhash测试结果
总结:php 自带hash mhash 用于散列只能加密 扩展mcrypt 用于加解密 对文件加密有的文件会隐藏换行,或者读取方式等影响导致结果不一致. 1.crc32 php: a.系统crc ...
- Mongodb数据库加密存储(python)
需求: 不知道大家有没有遇到过这样的需求:自己的服务器出于对数据库安全的保护,需要对存储的数据进行加密保护.这样万一数据库被人拿到,别人也不能拿到数据库里面的内容.这里还有一个前提:前端的展示页面是 ...
- Padding Oracle Attack的一些细节与实现
Padding Oracle Attack还是颇具威力的,ASP.NET的Padding Oracle Attack被Pwnie评为2010年最佳服务端漏洞之一.还是看 Juliano Rizzo a ...
- java几种常见加密算法小试
http://www.cnblogs.com/JCSU/articles/2803598.html http://www.open-open.com/lib/view/open139727425732 ...
- Java实验四 TCP客户端和服务器的应用
实验内容 1.掌握Socket程序的编写: 2.掌握密码技术的使用: 3.设计安全 4.对通信内容进行摘要计算并验证 实验步骤 1.信息安全传送: 发送方A——————>接收方B A加密时,用B ...
- OpenSSL命令---ciphers
用途: 指令是用来展示用于SSL加密算法的工具.它能够把所有openssl支持的加密算法按照一定规律排列(一般是加密强度).这样可以用来做测试工具,决定使用什么加密算法. 用法: openssl ci ...
- Python 3 加密简介
导读 Python 3 的标准库中是没多少用来解决加密的,不过却有用于处理哈希的库.在这里我们会对其进行一个简单的介绍,但重点会放在两个第三方的软件包:PyCrypto 和 cryptography ...
随机推荐
- python web
[root@xen202 wbk]# python -m SimpleHTTPServerServing HTTP on 0.0.0.0 port 8000 ...
- Html中隐藏a标签
<div><a href="#"><span style="visibility:hidden">我的</span&g ...
- Webbrowser控件execcommand参数详解
2D-Position 允许通过拖曳移动绝对定位的对象.AbsolutePosition 设定元素的 position 属性为“absolute”(绝对).BackColor 设置或获取当前选中区的背 ...
- poj3621 Sightseeing Cows --- 01分数规划
典型的求最优比例环问题 參考资料: http://blog.csdn.net/hhaile/article/details/8883652 此题中,给出每一个点和每条边的权值,求一个环使 ans=∑点 ...
- ZOJ3805:Machine
In a typical assembly line, machines are connected one by one. The first machine's output product wi ...
- grep命令参数和使用方法
功能说明:查找符合串的条件的文件. 语言 法国:grep [-abcEFGhHilLnqrsvVwxy][-A<显示列数>][-B<显示列数>][-C<显示列数>] ...
- 基于libevent, libuv和android Looper不断演进socket编程 - 走向架构师之路 - 博客频道 - CSDN.NET
基于libevent, libuv和android Looper不断演进socket编程 - 走向架构师之路 - 博客频道 - CSDN.NET 基于libevent, libuv和android L ...
- VS2010调用VLFeat
相比OpenCV,VLFeat的代码全是开源,并且非常重要的一点,事实上现的sift和Low的精度差点儿相同,这个团队全是码神,膜拜一下. 依照以下的网址进行安装,本人已经装上了,确实能够的. 安装參 ...
- GC日志分析
JVM的GC日志的主要參数包含例如以下几个: -XX:+PrintGC 输出GC日志 -XX:+PrintGCDetails 输出GC的具体日志 -XX:+PrintGCTimeStamps 输出GC ...
- js中点击空白区域时文本框与隐藏层的问题
当文本框获得焦点的时候,在文本框的下方显示一个浮动层. 当用户点击除了文本框和浮动层以外的网页空白处时,要隐藏浮动层. 当用户点击浮动层时,改变文本框的值. <!DOCTYPE html PUB ...