9 posts
Posted 26 July 2013 - 07:00 AM
I'm trying to make a safe password program. It should let the input go through an algorithm, to convert it completely into numbers. The output should be sent via rednet to a different computer, which compares it with the right code. If they are equal, the comparing computer sends an OK-message to the computer, I want to access. If not, it sends a NOT-OK-message. The problem I'm having is converting the strings into numbers. I've already googled quite a lot but I could not find anything helpful.
Thanks for your help,
PappleFruit
8543 posts
Posted 26 July 2013 - 12:39 PM
Split into new topic.
Look into string.byte and string.char.
9 posts
Posted 26 July 2013 - 01:22 PM
Thanks, but how can I get the number for each letter in a sentence? If I for example type in string.byte("Hello") it will just give me the number for H, not for the rest.
500 posts
Posted 26 July 2013 - 01:40 PM
Try doing something like this:
-- turn the string into a number
local str = "put your own string here"
local num = ""
for char in str:gmatch(".") do
num = num.. ( ("0"):rep(3 - #tostring(string.byte(char))) .. string.byte(char) )
end
-- turn the number into a string
local str2 = ""
for char in num:gmatch("...") do
str2 = str2 .. string.char(tonumber(char))
end
Note: It's actually a string that has number characters only for simplicity.
9 posts
Posted 26 July 2013 - 03:28 PM
Yeah, thanks for the code, totally did the trick for me. :)/>