Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Oct 2007
    Location
    Gensokyo
    Posts
    1,324

    [FREE] EasyEncryption Action Plugin

    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.

    Code:
    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(sMainKey, 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.

  2. #2
    Join Date
    Jun 2006
    Posts
    62
    Please make a Sample for newbie user same as I

  3. #3
    Join Date
    Jun 2006
    Posts
    62
    have not help me everybody ?

  4. #4
    Join Date
    Oct 2002
    Location
    RealFake, RF
    Posts
    403
    his sounds awesome. Could you put together a small apz for us to try out?

    Thanks for posting this!
    "White-colla-AMS-gangsta."

  5. #5
    Join Date
    Oct 2007
    Location
    Gensokyo
    Posts
    1,324
    If you insist.

  6. #6
    Join Date
    Oct 2002
    Location
    RealFake, RF
    Posts
    403
    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!
    "White-colla-AMS-gangsta."

  7. #7
    Join Date
    Oct 2002
    Location
    RealFake, RF
    Posts
    403
    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!

    "White-colla-AMS-gangsta."

  8. #8
    Join Date
    Oct 2002
    Location
    RealFake, RF
    Posts
    403
    I noticed that there is this function:

    Code:
    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.
    "White-colla-AMS-gangsta."

  9. #9
    Join Date
    Oct 2002
    Location
    RealFake, RF
    Posts
    403
    It's a bit "wordy", but for those interested in having this, add this to the Global Functions provided by Shadow. Works for me.

    Code:
    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!
    "White-colla-AMS-gangsta."

  10. #10
    Join Date
    May 2005
    Posts
    1,115
    If you want to make the function clean, use local variables.
    Never know what life is gonna throw at you.
    (Based on a true story.)

  11. #11
    Join Date
    Apr 2007
    Location
    Raalte, OV, Netherlands
    Posts
    3,287
    Quote Originally Posted by bule View Post
    If you want to make the function clean, use local variables.
    Agreed
    Bas Groothedde
    Imagine Programming :: Blog :: Familiar people here

    My AMS Plugins:

  12. #12
    Join Date
    Feb 2008
    Location
    Western Pennsylvania
    Posts
    555

    Grin Question

    Hey ShadowUK, stupid question, but where do i put the EasyEncrypt.lua???

  13. #13
    Join Date
    Apr 2007
    Location
    Raalte, OV, Netherlands
    Posts
    3,287
    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
    Bas Groothedde
    Imagine Programming :: Blog :: Familiar people here

    My AMS Plugins:

  14. #14
    Join Date
    Feb 2008
    Location
    Western Pennsylvania
    Posts
    555

    Oops I did

    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!

  15. #15
    Join Date
    Apr 2007
    Location
    Raalte, OV, Netherlands
    Posts
    3,287
    Quote Originally Posted by C B programming and webdesign View Post
    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
    Bas Groothedde
    Imagine Programming :: Blog :: Familiar people here

    My AMS Plugins:

Similar Threads

  1. FREE: UserMgmt Action Plugin
    By TimeSurfer in forum AutoPlay Media Studio 7.5
    Replies: 3
    Last Post: 04-11-2010, 09:21 PM
  2. API - Action Plugin Installer -- Beta II [HOT!!!]
    By TimeSurfer in forum AutoPlay Media Studio 7.5
    Replies: 7
    Last Post: 06-13-2008, 02:55 AM
  3. Spotlight: CD Audio Action Plugin
    By Desmond in forum AutoPlay Media Studio 5.0
    Replies: 16
    Last Post: 05-15-2006, 07:02 PM
  4. INFO: Tips for Debugging Action Lists in AutoPlay Media Studio 4.0
    By Support in forum AutoPlay Media Studio 4.0 Examples
    Replies: 0
    Last Post: 10-03-2002, 08:38 AM
  5. SUF6.0.0.2 -- installer hangs.
    By jassing in forum Setup Factory 6.0
    Replies: 4
    Last Post: 12-19-2001, 11:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts