3 Example for protecting/unprotecting SWFs.
5 Part of the swftools package.
7 Copyright (C) 2004 Matthias Kramm
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
24 #include "../rfxswf.h"
26 int main(int argn,char ** argv)
31 char* outfilename = "test.swf";
32 char*oldpassword = "fireworks";
33 char*newpassword = "cyberdine";
40 fi = open(argv[1],O_RDONLY|O_BINARY);
44 fprintf(stderr,"Couldn't open %s\n", argv[1]);
47 if(swf_ReadSWF(fi,&swf)<0)
49 fprintf(stderr,"%s is not a valid SWF file or contains errors.\n",argv[1]);
57 //void swf_SetPassword(TAG * t, const char * password);
58 //int swf_VerifyPassword(TAG * t, const char * password);
59 if(tag->id == ST_PROTECT) {
61 ret = swf_VerifyPassword(tag, oldpassword);
62 if(!ret) printf("Password validation failed\n");
63 else printf("Password ok\n");
70 tag = swf_InsertTag(swf.firstTag, ST_PROTECT);
71 swf_SetPassword(tag, newpassword);
73 fi = open(outfilename, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644);
75 fprintf(stderr, "couldn't create output file %s", outfilename);
77 if(swf_WriteSWF(fi, &swf)<0)
78 fprintf(stderr, "WriteSWF() failed.\n");