Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Hidden codes
- lemonyfresh23
-
Scratcher
5 posts
Hidden codes
]So I was wondering how someone would be able to make like a code or anything that you would need to type in order to progress, how would you keep someone from just being able to go into the code and cheat through it? I know this is a platform for learning, but I want to be able to have a code menu that doesn’t just straight up say in the code what the answer is. Like:
when green flag clickedSomeone can easily just see that. Can I somehow.. I don’t know hide it in a list or anything else?
set [ANSWER] to [4556]
ask [what’s the code?] and wait
if <[(answer)] = [ANSWER]> then
end
- CamG777
-
Scratcher
100+ posts
Hidden codes
I think it's impossible to make the code 100% secret but here are some methods you could use to make it a bit secure.
1) Add some math. This could be easily solved in a minute or two but is better then just having it lie around. Let's say the code is “5”
2) Numbers in a list. Again, could be cracked with a little effort. Let's say the code is “0123”
Create a list with numbers 1 to 9. In a random order. Let's say it's 9,1,8,2,7,3,6,4,5
1) Add some math. This could be easily solved in a minute or two but is better then just having it lie around. Let's say the code is “5”
ask [Code?] and wait
if <(((answer) + (2)) * (7.3)) = [51.1]> then
end
2) Numbers in a list. Again, could be cracked with a little effort. Let's say the code is “0123”
Create a list with numbers 1 to 9. In a random order. Let's say it's 9,1,8,2,7,3,6,4,5
ask [Code?] and wait
set [New Code v] to []
set [Counter v] to [1]
repeat (length of (answer))
set [New Code v] to (join (New Code) (item (letter (Counter) of (answer) ) of [list v] :: list))
change [Counter v] by (1)
end
if <(New Code) = [1982]> then
end
- NanoBug_
-
Scratcher
78 posts
Hidden codes
Maybe you could use lists to do this.
Last edited by NanoBug_ (Jan. 12, 2022 18:05:52)
- i_am_tankman
-
Scratcher
9 posts
Hidden codes
ask [code] and wait
if <(answer) = [your answer]> then
end
- SansStudios
-
Scratcher
1000+ posts
Hidden codes
You could do this with hash functions, but this won't prevent the user from just manually changing the code.
A hash function pretty much turns any text into different text with a set size. It is special because it is one-way meaning you can't “undo” a hash.
For example, the MD5 (a hash function) hash of “hello world” is 5eb63bbbe01eeed093cb22bb8f5acdc3. From 5eb63…, your users won't know that the original text was “hello world”.
Using a hash function, you could change your code to be like this:
Here's a super good video on hash functions: https://www.youtube.com/watch?v=b4b8ktEV4Bg
A hash function pretty much turns any text into different text with a set size. It is special because it is one-way meaning you can't “undo” a hash.
For example, the MD5 (a hash function) hash of “hello world” is 5eb63bbbe01eeed093cb22bb8f5acdc3. From 5eb63…, your users won't know that the original text was “hello world”.
Using a hash function, you could change your code to be like this:
ask [What is the code?] and wait
define Hash (text)
if <(hash result) = [5eb63bbbe01eeed093cb22bb8f5acdc3]> then
... // success code here!
end
Here's a super good video on hash functions: https://www.youtube.com/watch?v=b4b8ktEV4Bg
- CoolBoy4286
-
Scratcher
100+ posts
Hidden codes
(#1)Maybe you should encode it, these can be cracked but it's much better than just leaving it there.
]So I was wondering how someone would be able to make like a code or anything that you would need to type in order to progress, how would you keep someone from just being able to go into the code and cheat through it? I know this is a platform for learning, but I want to be able to have a code menu that doesn’t just straight up say in the code what the answer is. Like:
when green flag clickedSomeone can easily just see that. Can I somehow.. I don’t know hide it in a list or anything else?
set [ANSWER] to [4556]
ask [what’s the code?] and wait
if <[(answer)] = [ANSWER]> then
end
- 0to9
-
Scratcher
22 posts
Hidden codes
]So I was wondering how someone would be able to make like a code or anything that you would need to type in order to progress, how would you keep someone from just being able to go into the code and cheat through it? I know this is a platform for learning, but I want to be able to have a code menu that doesn’t just straight up say in the code what the answer is. Like:
when green flag clickedSomeone can easily just see that. Can I somehow.. I don’t know hide it in a list or anything else?
set [ANSWER] to [4556]
ask [what’s the code?] and wait
if <[(answer)] = [ANSWER]> then
end
A combination of math and encoding. Or just pick a random number.
- Discussion Forums
- » Help with Scripts
-
» Hidden codes











