453 posts
Location
Holland
Posted 01 October 2012 - 07:55 PM
i saw some encryption programs for lua on lua-users.org but they all require external C libraries. and i dont think CC can load those guys.
so if anyone has an encryption and decryption api ready or know one (with passwords) then i would like to use it!
thx in advance :)/>/>
wilcomega
871 posts
Posted 01 October 2012 - 08:12 PM
tomas1996's StringUtils includes some password-based encryption/decryption I think? It' a bit outdated now - some of it's functions are in the native stringutils library, and it's lua-based bitwise operations ought to be removed and the algos written to use the java-based ones in the new java-based bitwise api for cc 1.42+, but it's still usable as-is I assume. Not tried the encryption, only used the SHA1 function, but it worked well enough.
Link to his thread here
http://www.computercraft.info/forums2/index.php?/topic/42-cc13string-utils-api/
3790 posts
Location
Lincoln, Nebraska
Posted 01 October 2012 - 09:04 PM
What would be the application of this encryption? If it's simple, like a keycard system, you can use math.randomseed() to do a little jiggery… I'll come up with something a little easier to look at than just ideas soon…
3790 posts
Location
Lincoln, Nebraska
Posted 01 October 2012 - 09:38 PM
Strike that…I know nothing of what I am talking about….. Using math.randomseed() is super difficult to implement. Using someone else's pseudo-random number generator is not really a good idea.
521 posts
Location
Stockholm, Sweden
Posted 01 October 2012 - 11:18 PM
1604 posts
Posted 01 October 2012 - 11:29 PM
Well, it would be better to use a simple xor encryption:
local function xorEncrypt(data, key)
local klen = #key
local s = ""
for i = 1, #data do
s = s..string.char(bit.bxor(string.byte(data, i), string.byte(key, i % klen)))
end
return s
end
The same function works to encrypt and decrypt.
3790 posts
Location
Lincoln, Nebraska
Posted 01 October 2012 - 11:32 PM
That's more of a cipher than a true encryption… isn't it?
1604 posts
Posted 01 October 2012 - 11:33 PM
That's more of a cipher than a true encryption… isn't it?
Cipher = program that encrypts. :)/>/>
It's not a good algorithm and it's easy to break, but should be enough for most CC uses.
3790 posts
Location
Lincoln, Nebraska
Posted 01 October 2012 - 11:41 PM
Meh, I suppose.
Gonna try to implement this into some sort of keycard system.
2217 posts
Location
3232235883
Posted 02 October 2012 - 12:13 AM
i made a super secure one
here
521 posts
Location
Stockholm, Sweden
Posted 02 October 2012 - 12:40 AM
Well, it would be better to use a simple xor encryption:
local function xorEncrypt(data, key)
local klen = #key
local s = ""
for i = 1, #data do
s = s..string.char(bit.bxor(string.byte(data, i), string.byte(key, i % klen)))
end
return s
end
The same function works to encrypt and decrypt.
Well, I don't know anything about encrypting, I just fount that on the interwebs
3790 posts
Location
Lincoln, Nebraska
Posted 02 October 2012 - 12:48 AM
Well, I don't know anything about encrypting, I just fount that on the interwebs
Hooray for Google!!!
521 posts
Location
Stockholm, Sweden
Posted 02 October 2012 - 12:51 AM
Hooray for Google!!!
Google is your friend! (Not Yahoo or Bing!!)
:)/>/>