#๐Ÿ”’ decrypt

66 messages ยท Page 1 of 1 (latest)

radiant merlin
#

im trying to decrypt these 3 lines:

148AFAD1_1A7E4E98D94D48_317F9E76

72A9728_173A818E19F959_2EAD0A5A

F9786C0_10F071C4029F42_D0A8855

and the result for every line should be 217540394. I tried using basic math but i dont get the result that i want, this is my code:

def decode_line(line):
parts = line.split('_')
total = 0
for part in parts:
num = int(part, 16)
print(f"Parte: {part}, Decimal: {num}, Total parcial: {total}")
return total

line1 = "148AFAD1_1A7E4E98D94D48_317F9E76"
line2 = "72A9728_173A818E19F959_2EAD0A5A"
line3 = "F9786C0_10F071C4029F42_D0A8855"

total = decode_line(line1) + decode_line(line2) + decode_line(line3)
print(f"Total final: {total}")

this code gives the sum of every line, but i dont want that, i want the result (217540394)

pls help

fair ospreyBOT
#

@radiant merlin

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

cold trail
fair ospreyBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

cold trail
radiant merlin
#

!code

fair ospreyBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

radiant merlin
#
    parts = line.split('_') 
    total = 0
    for part in parts:
        num = int(part, 16)  
        print(f"Parte: {part}, Decimal: {num}, Total parcial: {total}") 
    return total

line1 = "148AFAD1_1A7E4E98D94D48_317F9E76"
line2 = "72A9728_173A818E19F959_2EAD0A5A"
line3 = "F9786C0_10F071C4029F42_D0A8855"


total = decode_line(line1) + decode_line(line2) + decode_line(line3)
print(f"Total final: {total}")
fair ospreyBOT
#

Hey @radiant merlin!

Please edit your message to use a code block

Add a py after the three backticks.

```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
radiant merlin
#

thats my code

cold trail
urban prism
#

"this code gives the sum of every line, but i want the result" yeah you told the code to do that. what did you expect it did?

#

do you even know what the "encryption" is? did you just ask an ai "hey can you generate code that decrypts this pls?"

radiant merlin
#

nope

#

im just askin what can i do to have the result

#

any idea

sweet crest
# radiant merlin any idea

let me walk you step by step through this:
your decode_line function has the total variable with an integer
your code decodes the lines and adds them to total. and crucially, total is returned while still an integer

on the last 2 lines, when you add the results of those functions, what you're basically doing is adding 3 numbers together. if you want to build a string, convert the results of those functions to strings:

total = str(decode_line(line1)) + str(decode_line(line2)) + str(decode_line(line3))

or use the fstring syntax you used in the last line:

print(f"Total final: {decode_line(line1)}{decode_line(line2)}{decode_line(line3)}")
radiant merlin
#

i made a mistake while copying my code

sweet crest
#

actually i just read what you asked, I was wrong
you want each result to be printed separately, right?

radiant merlin
#

kinda

sweet crest
#

then print statements for each decode_line result should be sufficient, no need to convert to str

radiant merlin
#

every line has to be decrypted and the result should be 217540394

sweet crest
sweet crest
#

or they all have to somehow be combined to that number?

#

oh

radiant merlin
#

217540394
217540394
217540394

#

like that

sweet crest
#

yeah then 3 print statments for the 3 results

radiant merlin
#

yep

sweet crest
#

then what's wrong?

radiant merlin
#
def decode_line(line):
    parts = line.split('_') 
    total = 0
    for part in parts:
        num = int(part, 16)
        total += num 
        print(f"Parte: {part}, Decimal: {num}, Total parcial: {total}") 
    return total

line1 = "148AFAD1_1A7E4E98D94D48_317F9E76"
line2 = "72A9728_173A818E19F959_2EAD0A5A"
line3 = "F9786C0_10F071C4029F42_D0A8855"


total = decode_line(line1) + decode_line(line2) + decode_line(line3)
print(f"Total final: {total}")
fair ospreyBOT
#

Hey @radiant merlin!

Please edit your message to use a code block

Add a py after the three backticks.

```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
radiant merlin
#

this was the code

#

the other code was wrong

#

but yeah, the same issue

#

i need an idea

#

to get 217540394 on each line

sweet crest
#

don't sum the decode_line results

#

print them separately

#
# total = decode_line(line1) + decode_line(line2) + decode_line(line3)
# print(f"Total final: {total}")
print(decode_line(line1))
print(decode_line(line2))
print(decode_line(line3))
#

assuming they really are the same when decoded

#

if you don't mind me asking, where did you get those lines? is this a puzzle/challenge or assignment? or something else

sweet crest
#

ah

radiant merlin
#

not even ai can help

sweet crest
#

let me test the code locally

radiant merlin
#

i was thinking like sum the first part and the second part and divide for the third part

#

like (a+b)/c

#

im testing

sweet crest
#

yeah thatll depend on the challenge question itself and what exactly it's asking then, I'm not sure what to do here

radiant merlin
#

CRYPTOGRAPHY CHALLENGE

148AFAD1_1A7E4E98D94D48_317F9E76

72A9728_173A818E19F959_2EAD0A5A

F9786C0_10F071C4029F42_D0A8855

The objective of the challenge is to create the program that can decode the previous lines, the same program must take each line individually and generate the same output

Each of the 3 lines must be decoded into the value 217540394 to know that the process was correct

sweet crest
#

ah thats all

radiant merlin
#

yep

sweet crest
#

i have a hunch, gimme a sec

#

yeah no clue

radiant merlin
#

yeah

#

its hard

#

all i know is that

#

these "_" are separators

#

i was using basic math like (a+b)/c

fair ospreyBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.