Problem Description
Bacon's cipher or the Baconian cipher is a method of steganography (a method of hiding a secret message as opposed to a true cipher) devised by Francis Bacon. A message is concealed in the presentation of text, rather than its content.  
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.

 
Input
The first line contains a positive number l, represents the length of the encoded string. L<=10000 and can be divided by 5. The second line is the encoded string.
 
Output
The original string.
 
Sample Input
35
ON1E2H5Q39AK2TGIC9ERT39B2P423L8B20D
 
Sample Output
FLEENOW
 

题意:给出一串密码,字母代表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的更多相关文章

  1. Bacon's Cipher(培根密码)

    Description Bacon's cipher or the Baconian cipher is a method of steganography (a method of hiding a ...

  2. Encryption and decryption、Steganography、Decryption Tools

    catalogue . 隐写术 . Substitution cipher . Transposition cipher . Bacon's cipher . LSB-Steganography 1. ...

  3. php crc32,md5,sha1,mhash测试结果

    总结:php  自带hash mhash 用于散列只能加密   扩展mcrypt 用于加解密 对文件加密有的文件会隐藏换行,或者读取方式等影响导致结果不一致. 1.crc32 php: a.系统crc ...

  4. Mongodb数据库加密存储(python)

     需求: 不知道大家有没有遇到过这样的需求:自己的服务器出于对数据库安全的保护,需要对存储的数据进行加密保护.这样万一数据库被人拿到,别人也不能拿到数据库里面的内容.这里还有一个前提:前端的展示页面是 ...

  5. Padding Oracle Attack的一些细节与实现

    Padding Oracle Attack还是颇具威力的,ASP.NET的Padding Oracle Attack被Pwnie评为2010年最佳服务端漏洞之一.还是看 Juliano Rizzo a ...

  6. java几种常见加密算法小试

    http://www.cnblogs.com/JCSU/articles/2803598.html http://www.open-open.com/lib/view/open139727425732 ...

  7. Java实验四 TCP客户端和服务器的应用

    实验内容 1.掌握Socket程序的编写: 2.掌握密码技术的使用: 3.设计安全 4.对通信内容进行摘要计算并验证 实验步骤 1.信息安全传送: 发送方A——————>接收方B A加密时,用B ...

  8. OpenSSL命令---ciphers

    用途: 指令是用来展示用于SSL加密算法的工具.它能够把所有openssl支持的加密算法按照一定规律排列(一般是加密强度).这样可以用来做测试工具,决定使用什么加密算法. 用法: openssl ci ...

  9. Python 3 加密简介

    导读 Python 3 的标准库中是没多少用来解决加密的,不过却有用于处理哈希的库.在这里我们会对其进行一个简单的介绍,但重点会放在两个第三方的软件包:PyCrypto 和 cryptography ...

随机推荐

  1. sqlserver 存储过程学习笔记(二) 在项目中的应用<多表分页>

    (1)存储过程建立 USE [NewPlat] GO /****** Object:  StoredProcedure [dbo].[usp_PagingLarge]    Script Date: ...

  2. Linux多线程服务端编程:使用muduo C++网络库

    内容推荐本 书主要讲述采用现代C++在x86-64 Linux上编写多线程TCP网络服务程序的主流常规技术,重点讲解一种适应性较强的多线程服务器的编程模型,即one loop per thread.这 ...

  3. 利用手工编码的方式对srtus2进行输入验证

    对action方法进行校验有两种方法一种是: 1手工编码书写 2一种是用xml 输入校验的流程: 1类型转化器对请求参数执行类型转化,并把转换后的值赋给action属性. 2.如果执行类型转化的过程中 ...

  4. vim经常使用命令总结

    vim 选择文本,删除,复制,粘贴   文本的选择,对于编辑器来说,是非常主要的东西,也常常被用到,总结例如以下: v    从光标当前位置開始,光标所经过的地方会被选中,再按一下v结束. V     ...

  5. nginx源代码分析--高性能server开发 常见的流程模型

    1.高性能server 对于高性能server对于.处理速度和占用空间小是典型特性.特别是当server经验C10K问题的时候(网络server在处理数以万计的client连接时.往往出现效率低下甚至 ...

  6. 三框架:使用数据源dbcp注意

    使用spring整合hibernate时间,需要使用该数据源,数据源使用apache的dbcp,使用dbcp当需要依靠pool的jar包.选择dbcp和pool当你需要注意. DBCP 2 compi ...

  7. 不错的C++框架: Thrift(2)-传输和网络相关

    不错的C++框架: Thrift(2)-传输和网络相关 - ang639 - 博客频道 - CSDN.NET 不错的C++框架: Thrift(2)-传输和网络相关

  8. hdu4487(概率dp)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4487 题意:开始位置在0,每一步可以向右向左或者不动,问走了n步后,路径中能到达最右的期望. 分析:d ...

  9. 添加PDF文件对照度的粗浅原理,及方法

      上边这张照片不是异形,而是著名的鹦鹉螺.下边这张照片,是送给研究生同学的毕业纪念,向龙同学帮我激光雕刻的. 近期的照片在[http://www.douban.com/photos/album/13 ...

  10. HDU2037 今年暑假不AC 【贪心】

    今年暑假不AC Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Su ...