加密/解密帮助 [英] Encryption/Decryption Help

查看:64
本文介绍了加密/解密帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨伙计们



这是我Sam,实际上我是c ++的新手学习者,我还没有走得那么远,到目前为止我刚刚研究了基本的东西,比如定义,循环和稍微变量,当我试图解决下面提到的问题时,我遇到了一个问题,我使用的是ASCCI,但我无法正常,我发现了程序中有很多错误,我希望其中一个人能尽快回复我。





你的国家处于战争状态,你的敌人正在使用密码来互相沟通。你设法拦截了一条消息

,内容如下:

:mmZ \ _dxZmx] Zpgy

消息显然是使用敌人的密码。你刚刚得知他们的加密方法是基于ASCII码的。

字符串中的各个字符都是用这个系统编码的。例如,

TCP1231计算机编程1作业1

Page 3 of 6

这封信?A?使用数字65进行编码,使用

数字66编码?B?

你的敌人的密码采用消息的每个字母并加密为<接下来是


如果(OriginalChar + Key> 126)那么

EncryptedChar = 32 +((OriginalChar + Key) - 127)

否则

EncryptedChar =(OriginalChar + Key)

例如,如果敌人使用Key = 10那么消息?嘿?将

加密为:

字符ASCII码

H
$ b $

y

72

101

102

加密H =(72 + 10)= 82 = ASCII中的R />
加密e =(101 + 10)= 111 = o用ASCII格式

加密y =((121 + 10) - 127)= 36 = $ in ASCII

因此,?嘿?将被传输为?Ro $ ?.

编写一个解密截获的消息的程序。您只知道

使用的密钥是1到100之间的数字。您的程序应该尝试使用1到100之间的所有可能密钥对消息进行解码。

尝试有效的密钥,这条消息会有意义。





问候:



sami alkindi



谢谢

hi guys



this is me Sam,actually i a new novice learner in c++ and i haven''t gone that further, so far i just studied the basic things,such as definitions,loops,and slightly about variables,i have faced a problem when i tried to solve the question which is stated below, i use the ASCCI but i couldn''t get properly, i found a lot of bugs in the program, i wish one of guys can respond me as soon as possible.






Your country is at war and your enemies are using a secret code to
communicate with each other. You have managed to intercept a message
that reads as follows:
:mmZ\dxZmx]Zpgy
The message is obviously encrypted using the enemy?s secret code. You
have just learned that their encryption method is based upon the ASCII code.
Individual characters in a string are encoded using this system. For example,
TCP1231 Computer Programming 1 Assignment 1
Page 3 of 6
the letter ?A? is encoded using the number 65 and ?B?is encoded using the
number 66.
Your enemy?s secret code takes each letter of the message and encrypts it as
follows:
If (OriginalChar + Key > 126) then
EncryptedChar = 32 + ((OriginalChar + Key) - 127)
Else
EncryptedChar = (OriginalChar + Key)
For example, if the enemy uses Key = 10 then the message ?Hey? would be
encrypted as:
Character ASCII code
H
e
y
72
101
102
Encrypted H = (72 + 10) = 82 = R in ASCII
Encrypted e = (101 + 10) = 111 = o in ASCII
Encrypted y = ((121 + 10) - 127) = 36 = $ in ASCII
Consequently, ?Hey? would be transmitted as ?Ro$?.
Write a program that decrypts the intercepted message. You only know that
the key used is a number between 1 and 100. Your program should try to
decode the message using all possible keys between 1 and 100. When you
try the valid key, the message will make sense.





Regards:


sami alkindi



thank you

推荐答案

用ASCII

结果,?嘿?将被传输为?Ro
in ASCII
Consequently, ?Hey? would be transmitted as ?Ro




编写一个解密截获的消息的程序。您只知道

使用的密钥是1到100之间的数字。您的程序应该尝试使用1到100之间的所有可能密钥对消息进行解码。

尝试有效的密钥,这条消息会有意义。





问候:



sami alkindi



谢谢
?.
Write a program that decrypts the intercepted message. You only know that
the key used is a number between 1 and 100. Your program should try to
decode the message using all possible keys between 1 and 100. When you
try the valid key, the message will make sense.





Regards:


sami alkindi



thank you


发布您的代码并更具体地说明您的问题。
Post your code and be more specific about your problem.


这篇关于加密/解密帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆