Hard Disk Serial Numbers & String shuffler
Thomas McCarthy
tominjapan at excite.com
Tue May 17 09:25:35 EDT 2005
This rev list is great. Very helpful. So I want to make a small contribution. Recently there were some threads about serial numbers getting them from disks and generating them to protect your work.
One mentioned taking a line and reversing it to help mask it. I recently made a code generator that goes one better, it takes the line and shuffles it: First, last, first last. Its easy, just take the first char, delete it, the last char, delete it and add them to your new string.
De-shuffling requires building two strings and then putting them together. Heres the decoder.
function decodeIt tregnum
--this will return a string in order
--i.e. from 51423 to 12345
put tregnum into t
put the num of chars in t into tlimit
repeat with i = 1 to tlimit
if i mod 2 > 0 then
put the first char of t before t2b
else
put the first char of t after t2a
end if
delete the first char of t
end repeat
put t2a & t2b into tregnum
return tregnum
end decodeIt
Ken Ray has some great stuff, naturally. However, some of his drive-serial number retrieval codes wont work on non-English systems (because they try to match (English) strings) Ive adapted some to look for -, a char in the serial number itself.
Here is a Mac/Win serial number function (the mac version is still English-dependent) and probably OSX only.
function driveNum
--Adapted from Ken Rays work
switch (the platform)
case "MacOS"
put shell ("system_profiler SPIDEDataType") into x
put lineoffset("Serial",x,20) into n this is my brilliant contribution. Will skip the first drive (CD)
put the last word of line (n + 20) of x into x
if x <> 0 then
return x
else
return "MacUser" if all else fails
end if
break
case "Win32"
--returns the hard drives number
put the first char of stackpath() into x this is a function that returns the path natch
--answer x --drive letter
-- Supports both "C", "C:" and "C:\" styles
put x & ":" into pDisk
set the hideConsoleWindows to true
put shell("dir " & pDisk) into tDirData
put lineoffset("-",tDirData) into x another brilliant contribution, this will work on non English systems
return the last word of line x of tDirData
break
end switch
end driveNum
Sorry I dont have enough time to keep up with this list! Very busy with a big project. I will probably be annoying the list with questions.
Cheers
Tom Mccarthy
_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!
More information about the use-livecode
mailing list