louie Posted October 14, 2005 Share Posted October 14, 2005 Is there a way to protect CSS files? Is there a way to somehow encrypt it? Or are there other means of doing it? Link to comment Share on other sites More sharing options...
Jonas Posted October 14, 2005 Share Posted October 14, 2005 Is there a way to protect CSS files? Is there a way to somehow encrypt it? Or are there other means of doing it?<{POST_SNAPBACK}> Why would you want to protect your css files? Link to comment Share on other sites More sharing options...
Chocolate570 Posted October 14, 2005 Share Posted October 14, 2005 First, don't post the file there, second, do a really complex way of posting it through js. For example.x = sy=cz=riptdocument.write("\<"x+y+z+" src=\"\"\>")If you wanted to cloak a script src. Most people use the find option for webpages, so that would hide it. Link to comment Share on other sites More sharing options...
Jonas Posted October 14, 2005 Share Posted October 14, 2005 First, don't post the file there, second, do a really complex way of posting it through js. For example.x = sy=cz=riptdocument.write("\<"x+y+z+" src=\"\"\>")If you wanted to cloak a script src. Most people use the find option for webpages, so that would hide it.<{POST_SNAPBACK}> Interesting concept... :)But I'd use:w=sx=cy=rz=iptso you can write "src" with "w"+"y"+"x"<wxyz wyx="something.xww" /> Link to comment Share on other sites More sharing options...
Chocolate570 Posted October 14, 2005 Share Posted October 14, 2005 Rofl, great point. But now on to his question.Do the same thing we just showed you, except with <link rel="Stylesheet" .... etc.> Link to comment Share on other sites More sharing options...
Jonas Posted October 14, 2005 Share Posted October 14, 2005 And, if you want to, you can even put the javascript code in an external file, and hide that too... Link to comment Share on other sites More sharing options...
louie Posted October 14, 2005 Author Share Posted October 14, 2005 Why would you want to protect your css files? <{POST_SNAPBACK}> Why would i want to protect my CSS files? coz a lot of people would just simply steal your code/layouts and claim it as theirs. you wouldnt want another copy of your website elsewhere. some people would simply copy/paste your code and (not even change a thing!) then they have an instant website, courtesy of you. But its not really a big deal. i was just wondering how to do it. Link to comment Share on other sites More sharing options...
Jonas Posted October 14, 2005 Share Posted October 14, 2005 Why would i want to protect my CSS files? coz a lot of people would just simply steal your code/layouts and claim it as theirs. you wouldnt want another copy of your website elsewhere. some people would simply copy/paste your code and (not even change a thing!) then they have an instant website, courtesy of you.<{POST_SNAPBACK}> I suppose. But it's through other people's code that you learn stuff. I for one have learned a lot by looking at other people's html and css. My own pride keeps me from just stealing another website, but I guess that doesn't apply to everyone... Link to comment Share on other sites More sharing options...
Chocolate570 Posted October 14, 2005 Share Posted October 14, 2005 darn stealers! (not the football team! )Well, if you want the complete code thing to hide the css, this is how it would go.<script src="http://hostofscript/script.js"></script>Inside that hosted script, would be this:document.write("<link rel=\'Stylesheet\' href=\'\' type="text/css">Where all bolded parts are up to you. I need a second opinion;would this work? Link to comment Share on other sites More sharing options...
louie Posted October 15, 2005 Author Share Posted October 15, 2005 Thanks a lot guys for the help/info. i tried doing one of your suggestions. it worked out quite fine but i figured it would be useless. coz i checked the temporary internet files folder. the css is always there. no matter what. the browser needs it i figure.but anyway. thanks a lot for the help. Link to comment Share on other sites More sharing options...
Jack McKalling Posted October 17, 2005 Share Posted October 17, 2005 Maybe you could try to execute a stylesheet by PHP, which won't be visible in the source :)But an external CSS file, would always be visible for the browser in the end... Writing in PHP makes it internal, so making it directly visible in the source code. Link to comment Share on other sites More sharing options...
Chocolate570 Posted October 17, 2005 Share Posted October 17, 2005 <?php$txt="<link rel=\'Stylesheet\' href=\'\' type="text/css";echo $txt;?>I guess..i don't know php. would that work? Link to comment Share on other sites More sharing options...
Jonas Posted October 17, 2005 Share Posted October 17, 2005 <?php$txt="<link rel=\'Stylesheet\' href=\'\' type="text/css";echo $txt;?>I guess..i don't know php. would that work?<{POST_SNAPBACK}> I'm pretty sure that would be the equivalent to javascript's document.write('...')But I could of course be wrong... Link to comment Share on other sites More sharing options...
Jack McKalling Posted October 17, 2005 Share Posted October 17, 2005 (edited) Are you playing Memory? :)Yes, that PHP would be the same as the javascript thing.Something like this:<?php$fr = fopen("your_CSS_file.css",r);while (!feof($fr)) { echo fgetc($fr,1000); }?>It may be invalid PHP, inthere I am a beginner. But like this, you'd write the CSS file directly inside the current file, so it would turn into internal, no css file needed.Use this information whatever you like Edited October 17, 2005 by Dan The Prof Link to comment Share on other sites More sharing options...
Jonas Posted October 17, 2005 Share Posted October 17, 2005 Are you playing Memory? <{POST_SNAPBACK}> Either that, or I'm playing humble... Link to comment Share on other sites More sharing options...
Webworldx Posted October 17, 2005 Share Posted October 17, 2005 I'm a big fan of this encryption:http://www.protware.com/demo_e.htm Check the source. Link to comment Share on other sites More sharing options...
Chocolate570 Posted October 18, 2005 Share Posted October 18, 2005 Wierd. Except, it has nothing on the page! Link to comment Share on other sites More sharing options...
louie Posted October 19, 2005 Author Share Posted October 19, 2005 I'm a big fan of this encryption:http://www.protware.com/demo_e.htm Check the source.<{POST_SNAPBACK}> I dnt see anything on the page. i viewed the source. it only has <HTML></HTML>uhm... is that it? or am i missing something here? Link to comment Share on other sites More sharing options...
louie Posted October 19, 2005 Author Share Posted October 19, 2005 i think somehow i found what im looking for. http://www.rlrouse.com/html-encryptor.htmlIt uses javascript. And you can encript not just css... They can still view/save the css file but in an encripted format and i dnt really think they can edit it that easily because they have to decrypt it first. But maybe there is still a downside.there is also an offline version for it.Tell me what you guys think. Link to comment Share on other sites More sharing options...
qugh Posted October 22, 2005 Share Posted October 22, 2005 (Chocolate570 @ Oct 17 2005, 10:54 PM)<?php$txt="<link rel=\'Stylesheet\' href=\'\' type="text/css";echo $txt;?>I guess..i don't know php. would that work?I'm pretty sure that would be the equivalent to javascript's document.write('...')No, that's incorrect... PHP compiles at run time, completely unlike Javascript. This means that you write the code (as above) and when a user hits that page, PHP spits out the proper html, so you aren't encoding anything. Even if you were to try to right click->'save target as' on the link referring to the page, it would only show the compiled page... never the original source code. This is because it's a server-side language (like ASP, ASP.NET, Java, JSP, Coldfusion, etc) which means it compiles right before it's sent to you (on the host server).<?php$txt="<link rel=\'Stylesheet\' href=\'\' type="text/css";echo $txt;?>would still output:<link rel='Stylesheet' href='' type="text/css" (on a side note... that line of code would error because the quotes around text/css aren't backslashed as well)Moving on... Javascript always shows the source code and compiles based on the user's browser. It's called a 'client-side' language. Have you ever noticed that Javascript will work differently in different browsers? That's because of what I'm saying... Javascript doesn't hide source code (and never will), while PHP will always hides source code. Two completely different languages.I hope this makes sense to you and I helped shed some light on that.Finally, a good note! http://scriptasylum.com/tutorials/encdec/encode-decode.html is a good way to encode your javascript so it's difficult to for anyone to steal. Doesn't mean it's impossible, just that it will knock out 99% of the people trying. Just make sure your javascript is perfect before you encode it, AND DON'T FORGET TO SAVE YOUR ORIGINAL JAVASCRIPT!Happy coding! Link to comment Share on other sites More sharing options...
Jack McKalling Posted November 23, 2005 Share Posted November 23, 2005 So we have come to the conclusion, that CSS style files will be stored at the user's pc, for later reuse, and that the user can refer to it and steal the content.I do not know many about the following, but it might work.How about, expire the cached file? Would it then be deleted after the expire date, or directly downloaded after that date when called again?If the first case is true, try to write the css with php, and sent a content-type header. (header before the content) Set expire date exactly the current time plus 1 (to ensure the file can be used at all).This way the file gets deleted directly after use, instead of leaving it in the cache.Right? Link to comment Share on other sites More sharing options...
Skemcin Posted November 23, 2005 Share Posted November 23, 2005 Either way, I would still be able to directly call the CSS by viewing the source and typing the absolute path into my browser. Then I'd just need to copy and past the contents.To my knowledge, there is no way you will truely be able to protect your CSS. Scripting language code is different since it is processed - CSS files are just referenced. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now