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 ...
随机推荐
- crontab linux
第1列分钟1-59第2列小时1-23(0表示子夜)第3列日1-31第4列月1-12第5列星期0-6(0表示星期天)第6列要运行的命令 下面是crontab的格式:分 时 日 月 星期 要运行的命令 这 ...
- C语言函数调用约定
在C语言中,假设我们有这样的一个函数: int function(int a,int b) 调用时只要用result = function(1,2)这样的方式就可以使用这个函数.但是,当高级语言被编译 ...
- Webbrowser控件execcommand参数详解
2D-Position 允许通过拖曳移动绝对定位的对象.AbsolutePosition 设定元素的 position 属性为“absolute”(绝对).BackColor 设置或获取当前选中区的背 ...
- Pods was rejected as an implicit dependency for 'libPods.a' because its architectures 'x86_64' didn
引入cocoaPods后.第一次编译,或者运行update后 可能报这个错误: Pods was rejected as an implicit dependency for 'libPods.a' ...
- 【剑指offer】不用加减乘除做加法
转载请注明出处:http://blog.csdn.net/ns_code/article/details/27966641 题目描写叙述: 写一个函数,求两个整数之和,要求在函数体内不得使用+.-.* ...
- Linux Shell 函数返回值
Shell函数返回值,常用的两种方式:return,echo 1) return 语句 shell函数的返回值,可以和其他语言的返回值一样,通过return语句返回. 示例: #!/bin/sh fu ...
- <xliff:g>标签
摘要: 这是Android4.3Mms源代码中的strings.xml的一段代码: <!--Settings item desciption for integer auto-delete sm ...
- C#List<long>与String(Linq)
1.string => List<long> string ShopIds = "1,2,3"; var ShopIdList = ShopIds.Split(' ...
- HDOJ 3516 Tree Construction
四边形优化DP Tree Construction Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Jav ...
- Android它SDK Manager无法更新终极解决方案
前些日子.Google终于发布Android5.0正式版--棒糖.也许你和我一样,,此外,我想在第一时间更新SDK,结果打开SDK Manager,但令人失望,络围墙啊.默默问一句:近期好久没有听到方 ...