//James Parks //06-03-02 //jpProtect.mel //This script will password protect your Maya file. //It accomplishes this by creating a scriptNode that //prompts you for a password as soon as the file is //opened. The file doesn't fully open until you have //entered the proper password. If you don't know the //password, too bad. //The major weakness here is that the password is //stored as normal plain text in a script node. This //means that the password may be read and edited if //you save your file as an .ma (Maya ASCII) file. //To run this script source it in Maya and type //"jpProtect" in the script editor or command line. global proc jpProtect() { global string $magicWord; string $protectWin = "jpProtect"; if (`window -exists $protectWin`) deleteUI $protectWin; window -t "Password Protect" -wh 200 35 -rtf 1 $protectWin; rowColumnLayout -nr 2 -rh 1 25 -rh 2 20 ; rowColumnLayout -nc 2 //-cw 1 100 //-cw 2 100 ; textFieldGrp //-l "Password" //-w 50 //-h 25 -cal 1 "left" //-cal 2 "left" -tx "Password" passGrp ; button -w 100 -l "Protect" -c ("createMagic(); deleteUI -wnd " + $protectWin); setParent ..; button -w 200 -l "Delete Existing Password" -c "delete passwordScript"; showWindow $protectWin; } global proc createMagic() { global string $magicWord; $magicWord = `textFieldGrp -q -tx passGrp`; createNode script -n "passwordScript"; setAttr ".b" -type "string" ( "//This scriptNode provides password protection for your \r\n" + "//Maya File.\r\n" + "//\r\n" + "//\r\n" + "//\r\n" + "//\r\n" + "global string $mWord = \"" + $magicWord + "\";\r\n" + "\r\n" + "global proc Pass()\r\n" + "{\r\n" + "global string $mWord;\r\n" + "promptDialog\r\n" + " -title \"Password\"\r\n" + " -message \"What's the Magic Word?\"\r\n" + " -button \"OK\" \r\n" + " -defaultButton \"OK\" ;\r\n" + "string $ans = `promptDialog -q -text`;\r\n" + "if($ans != $mWord)\r\n" + "{\r\n" + " pause -sec 5;\r\n" + " Pass();\r\n" + "}\r\n" + "}\r\n" + "\r\n" + "Pass;"); setAttr ".st" 1; print ("File protected with password: " + $magicWord); } jpProtect;