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. Abot 爬虫

    Abot 爬虫分析-整体结构 1. 引言 在Github 上搜索下Web Crawler 有上千个开源的项目,但是C#的仅仅只有168 个,相比于Java 或者Python 确实少的可怜.如果按照St ...

  2. 经典的C++库【转帖】

    源地址:http://www.deuxmille.org/archives/1472 基础类1. Dinkumware C++ Library 参考站点:http://www.dinkumware.c ...

  3. linux route命令的使用详解

    route命令用于显示和操作IP路由表.要实现两个不同的子网之间的通信,需要一台连接两个网络的路由器,或者同时位于两个网络的网关来实现.在Linux系统中,设置路由通常是 为了解决以下问题:该Linu ...

  4. 检查java class的版本号

    补丁总是会一遍又一遍的打,越打越多 有时候,就担心有人不小心把高版本的class打到低版本jre运行的环境中 简单写了点代码,检查文件夹中class的版本号 package org.wee.cv; i ...

  5. [Android学习笔记]Unable to execute dex Multiple dex files define:xxxx 问题

    dex filse: Dalvik Execute Files , 即Android虚拟机可执行程序 从字面意思理解是你一个应用中,出现了多个Dex文件定义. 以下情况会出现此错误: 1.你项目中可能 ...

  6. [Android学习笔记]捕获物理回退事件

    物理回退按钮默认情况下是finish当前activity,返回上一个activity 当需要获取物理回退按钮的相应事件时候,可以这么做 步骤如下: 1.override当前activity的onKey ...

  7. hdu4059 The Boss on Mars

    The Boss on Mars Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  8. hdu 1561 The more, The Better (依赖背包 树形dp)

    题目: 链接:点击打开链接 题意: 非常明显的依赖背包. 思路: dp[i][j]表示以i为根结点时攻击j个城堡得到的最大值.(以i为根的子树选择j个点所能达到的最优值) dp[root][j] = ...

  9. 服务器编程入门(1)TCP/IP协议族

    问题聚焦: 简单地梳理一下TCP/IP各层的功能和常用协议 详细了解ARP(数据链路层)和DNS(应用层)协议的工作原理 1 TCP/IP协议族体系结构 数据链路层:     职责:实现网卡接口的网络 ...

  10. SVN的revert和update命令的区别

    svn中的revert和update 今天有人问到revert和update的问题. 刚开始还真被问住了. 因为感觉revert和update都可以将本地的copy更新到以前的一个版本,会有什么不同呢 ...