PDA

View Full Version : [FREE] EasyEncryption Action Plugin


ShadowUK
06-15-2008, 07:49 AM
People find encryption in their scripts hard. With this action plugin, It's easy. It contains 3 different catergorys.


FileEncrypt
RegistryEncrypt
StringEncrypt


For some reason, when put in the _notification_messages.lua, It doesnt work. So stick it in On Preload or something.

FileEncrypt = {};
RegistryEncrypt = {};
StringEncrypt = {};

function FileEncrypt.WriteFromString(sFile, sKey, sText)
if (sFile == "" or sFile == nil) then
error("FileEncrypt.WriteFromString: No file specified.");
end

if (sKey == "" or sKey == nil) then
error("FileEncrypt.WriteFromString: No key specified.");
end

if (sText == "" or sText == nil) then
error("FileEncrypt.WriteFromString: Text not specified.");
end

TextFile.WriteFromString(sFile, Crypto.BlowfishEncryptString(sText, sKey, 0), false);
end

function FileEncrypt.WriteFromTable(sFile, sKey, tText)
if (sFile == "" or sFile == nil) then
error("FileEncrypt.WriteFromTable: No file specified.");
end

if (sKey == "" or sKey == nil) then
error("FileEncrypt.WriteFromTable: No key specified.");
end

if (type(tText) ~= "table") then
error("FileEncrypt.WriteFromTable: Text not specified.");
end

TextFile.WriteFromString(sFile, Crypto.BlowfishEncryptString(Table.Concat(tText, "\r\n", 1, -1), sKey, 0), false);
end

function FileEncrypt.ReadToString(sFile, sKey)
if (sFile == "" or sFile == nil) then
error("FileEncrypt.ReadToString: No file specified.");
end

if (sKey == "" or sKey == nil) then
error("FileEncrypt.ReadToString: No key specified.");
end

return Crypto.BlowfishDecryptString(TextFile.ReadToString (sFile), sKey)
end

function FileEncrypt.GetEncryptedString(sFile)
if (File.DoesExist(sFile)) then
return TextFile.ReadToString(sFile);
end
end

function FileEncrypt.GetEncryptedTable(sFile)
if (File.DoesExist(sFile)) then
return TextFile.ReadToTable(sFile);
end
end

function RegistryEncrypt.WriteValue(sMainKey, sSubkey, sValue, sData, sType, sEncryptionKey)
if (sMainKey and sSubkey and sValue and sData and sType and sEncryptionKey) then
Registry.SetValue(sMainKey, sSubkey, sValue, Crypto.BlowfishEncryptString(sData, sEncryptionKey, 0), sType);
end
end

function RegistryEncrypt.ReadValue(sMainKey, sSubkey, sValue, sDecryptionKey)
if (sMainKey and sSubkey and sValue and sDecryptionKey) then
return Crypto.BlowfishDecryptString(Registry.GetValue(sMa inKey, sSubkey, sValue, bAutoExpand), sDecryptionKey)
end
end

function StringEncrypt.EncryptString(sText, sKey)
if (sText and sKey) then
return Crypto.BlowfishEncryptString(sText, sKey, 0);
end
end

function StringEncrypt.DecryptString(sText, sKey)
if (sText and sKey) then
return Crypto.BlowfishDecryptString(sText, sKey);
end
end

Files included, Have a nice day.

123456789
06-16-2008, 03:21 AM
Please make a Sample for newbie user same as I:eek:

123456789
06-19-2008, 04:37 AM
have not help me everybody ?:huh

Protocol
10-09-2008, 03:42 PM
his sounds awesome. Could you put together a small apz for us to try out?

Thanks for posting this!

ShadowUK
10-10-2008, 12:42 AM
If you insist.

Protocol
10-10-2008, 10:29 AM
VERY cool shadow. Compact and effective. I've got a project I'm working on right now that uses a simple admin password. I was trying to figure out the quickest way to encrypt it, but my old method of encapsulating it in an encrypted zip was going to take too long in both development and runtime.

This is perfect. I'm sure a lot of other peeps will agree...

Thank you for posting this to the community!

Protocol
10-11-2008, 05:56 PM
Again, this is great Shadow! I noticed that there's no FileEncrypt.ReadToTable function (to read an encoded text file and store its line-by-line contents as a table). Is there any way you can modify it to include this? I could write one myself, but it seems like this might be a good addition to the set for everyone and you'd know the best way to do it to match the rest of the code.

If no, I can come up with something. Just putting it out there. This is perfect!

:yes

Protocol
10-12-2008, 11:07 AM
I noticed that there is this function:

function FileEncrypt.GetEncryptedTable(sFile)
if (File.DoesExist(sFile)) then
return TextFile.ReadToTable(sFile);
end
end

But it doesn't return a decrypted table, only an encrypted string. I'm working on a resolution now, but just wanted to correct my last post.

Protocol
10-12-2008, 11:10 PM
It's a bit "wordy", but for those interested in having this, add this to the Global Functions provided by Shadow. Works for me.

function FileEncrypt.ReadToTable(sFile, sKey)
if (sFile == "" or sFile == nil) then
error("FileEncrypt.ReadToTable: No file specified.");
end

if (sKey == "" or sKey == nil) then
error("FileEncrypt.ReadToTable: No key specified.");
end

DecryptedTable = {};
DecryptedText = Crypto.BlowfishDecryptString(TextFile.ReadToString (sFile), sKey)
Search = String.Find(DecryptedText, "\r\n", 1, true);
while (Search ~= -1) do
Search = String.Find(DecryptedText, "\r\n", 1, true);
DecryptedLine = String.Left(DecryptedText, Search);
DecryptedText = String.TrimLeft(DecryptedText, DecryptedLine.."\r\n");
DecryptedTableCount = Table.Count(DecryptedTable);
Table.Insert(DecryptedTable, (DecryptedTableCount + 1), DecryptedLine);
end

return DecryptedTable
end


Thanks again, Shadow!

bule
10-13-2008, 01:11 AM
If you want to make the function clean, use local variables.

Imagine Programming
11-14-2008, 08:47 AM
If you want to make the function clean, use local variables.

Agreed:yes

JDog37
11-22-2008, 08:18 AM
Hey ShadowUK, stupid question, but where do i put the EasyEncrypt.lua???:huh

Imagine Programming
11-22-2008, 09:31 AM
you can put it in your Global Functions, or in your projects script folder and use RunScriptFile... the best way is appending it to _notification_messages.lua located in

Programfilespath\AutoPlay Media Studio 7.0\Data\Includes

JDog37
11-22-2008, 09:48 AM
I tried to do it but it wont work???? I put it in the data/include, but there is one there so I replaced it but it still didnt work! :wow:wow

Imagine Programming
11-22-2008, 11:18 AM
you can put it in your Global Functions, or in your projects script folder and use RunScriptFile... the best way is appending it to _notification_messages.lua located in

Programfilespath\AutoPlay Media Studio 7.0\Data\Includes

not in that folder... in the file _notification_messages.lua

JDog37
11-22-2008, 06:02 PM
I'll try it C B programming and webdesign... Thank You! :yes