#21
Posted 03 March 2012 - 08:36 AM
#22
Posted 04 March 2012 - 10:10 AM
Re-factoring of code,
Added:
CRC32(str) --Returns CRC32 Hash of @str
FCS16(str) --Returns FCS16 Hash of @str
FCS32(str) --Returns FCS32 Hash of @str
replace(str, from, to) --Replaces @from to @to in @str
#23
Posted 04 March 2012 - 12:24 PM
#24
Posted 05 March 2012 - 12:39 AM
How to reproduce :
StrUtil.decrypt("test", "somekey")
#25
Posted 05 March 2012 - 02:51 AM
Liraal, on 04 March 2012 - 12:24 PM, said:
Yes the license is included, There is a separate license file included in the download, But it is also included at the top of the API file. Yes it is fine, as long as you clearly state on the thread that it is mine.
Garthog, on 05 March 2012 - 12:39 AM, said:
How to reproduce :
StrUtil.decrypt("test", "somekey")
It is because you are trying to decrypt an unencrypted string.
#26
Posted 05 March 2012 - 10:57 AM
#27
Posted 05 March 2012 - 11:23 AM
Garthog, on 05 March 2012 - 10:57 AM, said:
Quick Fix:
Open String Utils change the decrypt function to:
function decrypt(str, key) --Decrypts @str with @key if not key then return nil end str = tostring(str) local key = SHA1(key) local strLen = str:len() local keyLen = key:len() local j=1 local result = "" for i=1, strLen, 2 do local ordStr = basen(tonumber(string.reverse(str:sub(i, i+1)),36),10) if j==keyLen then j=1 end local ordKey = string.byte(key:sub(j,j)) local nxChar = ordStr-ordKey if nxChar<0 or nxChar>255 then nxChar = 0 end result = result..string.char(nxChar) j = j+1 end return result:sub(11) end
#28
Posted 29 March 2012 - 10:39 AM
function isEmailAddress(str) --Checks if @str is a valid email address
if not str then return nil end
str = tostring(str)
if (str:match("[A-Za-z0-9%.%%%+%-][email protected][A-Za-z0-9%.%%%+%-]+%.%w%w%w?%w?")) then
return true
else
return false
end
end
Does this match all valid email addresses?
They don't necessarily contain dots or 2-4 letter TLDs. Or even alphabetic TLDs.
[email protected] is a perfectly valid email address, so is [email protected] (even though .music doesn't exist) or [email protected] or even "hi there!"@foo (if I interpreted RFC 822 correctly)
#29
Posted 25 May 2012 - 04:00 AM
function trim(str) --Trim @str of initial/trailing whitespace
if not str then return nil end
str = tostring(str)
return (str:gsub("^%s*(.-)%s*$", "%1"))
endThe above code could be written as:function trim(str) --Trim @str of initial/trailing whitespace
return tostring(str):gsub("^%s*(.-)%s*$", "%1")
end
Both functions here would successfully return nil if passed nil, enabling you to return nil.Also assigning the variable as its tostringed self is unnecessary since you can pass the return of tostring to gsub as demonstrated without needing it set to a variable.Wrapping the return in parenthesis only suppresses the gsub's additional return values but there's no reason to do that since it helps someone to determine whether or not the string was actually trimmed.
#30
Posted 01 July 2012 - 07:22 PM
#31
Posted 02 July 2012 - 12:37 AM
Graypup, on 01 July 2012 - 07:22 PM, said:
Here's the file you'll need with only the SHA1 stuff in it for you: https://bitbucket.or...5fc0ec/SHA1.lua
#32
Posted 02 July 2012 - 04:14 PM
I'm trying to make the OS as secure as possible, so encryption certainly helped.
#33
Posted 06 July 2012 - 12:35 AM
StrUtil.toHex(read())
But when I run the program it fails with the following error:
startup:4: attempt to index ? (a nil value)
I really don't know how to fix this except by using read() by itself. Thanks in advance for any help.
#34
Posted 06 July 2012 - 12:44 AM
nintendofan345, on 06 July 2012 - 12:35 AM, said:
StrUtil.toHex(read())
But when I run the program it fails with the following error:
startup:4: attempt to index ? (a nil value)
I really don't know how to fix this except by using read() by itself. Thanks in advance for any help.
EDIT:
Try with StrUtils instead of StrUtil, that should fix it
#35
Posted 06 July 2012 - 01:26 AM
#36
Posted 28 July 2012 - 10:46 PM
#37
Posted 05 August 2012 - 10:31 PM
#38
Posted 05 August 2012 - 10:36 PM
ETHANATOR360, on 05 August 2012 - 10:31 PM, said:
You need to put the name the api is saved as in front.
So if you saved it as StrUtil then you would do
StrUtil.toOctal("Hi")
#39
Posted 05 August 2012 - 11:39 PM
#40
Posted 05 August 2012 - 11:49 PM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











