Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Source Code Encryption

Source Code Encryption

Scheduled Pinned Locked Moved C#
security
31 Posts 11 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K kKamel

    I want it to be encrypted on the client side. I do not want the user to see my source for security purposes

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #9

    khalil.kamel wrote:

    for security purposes

    Security by Obscurity[^] does not provide real protection. Furthermore, if you are talking about your executable, what do you think encryption it will do? How could you expect the CPU to run code that it does not know? Unless it decrypts it first, but the user has the same knowledge as the CPU, which now apparently includes all information necessary to decrypt it, so you gain nothing. [edit]Ok I starting posting before that last post of yours. The same principle applies. How does the browser know what to render if it doesn't have the source?

    K 1 Reply Last reply
    0
    • L Lost User

      khalil.kamel wrote:

      for security purposes

      Security by Obscurity[^] does not provide real protection. Furthermore, if you are talking about your executable, what do you think encryption it will do? How could you expect the CPU to run code that it does not know? Unless it decrypts it first, but the user has the same knowledge as the CPU, which now apparently includes all information necessary to decrypt it, so you gain nothing. [edit]Ok I starting posting before that last post of yours. The same principle applies. How does the browser know what to render if it doesn't have the source?

      K Offline
      K Offline
      kKamel
      wrote on last edited by
      #10

      What am talking about is i do not want the client when he clicks view page source to view the javascript functions the control ids and so on...

      L A D C 4 Replies Last reply
      0
      • K kKamel

        What am talking about is i do not want the client when he clicks view page source to view the javascript functions the control ids and so on...

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #11

        So was I, in the part after the edit. How do you expect the browser to execute encrypted JavaScript, without decrypting it first? You couldn't decrypt it first, because that would mean giving away the decryption code on a silver platter.

        K 1 Reply Last reply
        0
        • L Lost User

          So was I, in the part after the edit. How do you expect the browser to execute encrypted JavaScript, without decrypting it first? You couldn't decrypt it first, because that would mean giving away the decryption code on a silver platter.

          K Offline
          K Offline
          kKamel
          wrote on last edited by
          #12

          Well I swear i know what are you saying and i do not know what did that person did but i really want to know how did he did it. Does any body has any suggestion?

          I L P N 4 Replies Last reply
          0
          • K kKamel

            Well I swear i know what are you saying and i do not know what did that person did but i really want to know how did he did it. Does any body has any suggestion?

            I Offline
            I Offline
            Ian Shlasko
            wrote on last edited by
            #13

            From your description in the other post, all your coworker did was remove the "View Source" option from the menu, probably using a javascript function. This is not secure. It's just aesthetic. It only makes it a little more difficult to view the source, NOT impossible.

            Proud to have finally moved to the A-Ark. Which one are you in? Developer, Author (Guardians of Xen)

            K 1 Reply Last reply
            0
            • K kKamel

              Well I swear i know what are you saying and i do not know what did that person did but i really want to know how did he did it. Does any body has any suggestion?

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #14

              I have a suggestion of how to make it "slightly harder" to quickly see all JavaScript: put the real code in a base64-encoded string, decode that and write that to the page in a normal function that people can see. It won't stop a hacker, but it may stop the bored school kids who have nothing better to do than messing around with people's sites. Don't rely on it.

              1 Reply Last reply
              0
              • K kKamel

                What am talking about is i do not want the client when he clicks view page source to view the javascript functions the control ids and so on...

                A Offline
                A Offline
                Adam R Harris
                wrote on last edited by
                #15

                Well you can use JScript.Ecode[^] (MSDN[^] )but that really isn't very secure because anyone can decode it using the utility that is free from MS. Once your JScript is encoded just set the Type on the script tag to "JScript.Encode" But it will stop your know nothing users from getting the source of your JScript. You should also put all your JS in a separate file and include it ... just another step for someone to decode it. Another option would be to use AJAX to load all of your scripts and stuff, that way if the user views source they will only see the content that was originally sent to the browser and not anything AJAX has loaded. The AJAX method is the best in my opinion but it could cause you to have to re-write your entire project to get rendered this way (read as PAIN IN THE A$$)

                If at first you don't succeed ... post it on The Code Project and Pray.

                1 Reply Last reply
                0
                • K kKamel

                  What am talking about is i do not want the client when he clicks view page source to view the javascript functions the control ids and so on...

                  D Offline
                  D Offline
                  DarkSorrow38
                  wrote on last edited by
                  #16

                  Don't know about Web Application however i encrypt windows appilcation using Java. If you wish i can give you a whole bunch of security keys.

                  1 Reply Last reply
                  0
                  • K kKamel

                    I want to encrypt my source code how can this be accomplished.

                    A Offline
                    A Offline
                    Adam R Harris
                    wrote on last edited by
                    #17

                    Well you can use JScript.Ecode[^] (MSDN[^])but that really isn't very secure because anyone can decode it using the utility that is free from MS. Once your JScript is encoded just set the Type on the script tag to "JScript.Encode" But it will stop your know nothing users from getting the source of your JScript. You should also put all your JS in a separate file and include it ... just another step for someone to decode it. Another option would be to use AJAX to load all of your scripts and stuff, that way if the user views source they will only see the content that was originally sent to the browser and not anything AJAX has loaded. The AJAX method is the best in my opinion but it could cause you to have to re-write your entire project to get rendered this way (read as PAIN IN THE A$$)

                    If at first you don't succeed ... post it on The Code Project and Pray.

                    1 Reply Last reply
                    0
                    • I Ian Shlasko

                      From your description in the other post, all your coworker did was remove the "View Source" option from the menu, probably using a javascript function. This is not secure. It's just aesthetic. It only makes it a little more difficult to view the source, NOT impossible.

                      Proud to have finally moved to the A-Ark. Which one are you in? Developer, Author (Guardians of Xen)

                      K Offline
                      K Offline
                      kKamel
                      wrote on last edited by
                      #18

                      How??

                      I 1 Reply Last reply
                      0
                      • K kKamel

                        Well I swear i know what are you saying and i do not know what did that person did but i really want to know how did he did it. Does any body has any suggestion?

                        P Offline
                        P Offline
                        Pete OHanlon
                        wrote on last edited by
                        #19

                        You can override the context menu to "hide" the view page source option, but it won't remove it from the browser menu. There is no way to completely remove the ability to view the page source because it must be sent down in a way that the web browser can interpret and display it.

                        "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                        As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                        My blog | My articles | MoXAML PowerToys | Onyx

                        K 1 Reply Last reply
                        0
                        • P Pete OHanlon

                          You can override the context menu to "hide" the view page source option, but it won't remove it from the browser menu. There is no way to completely remove the ability to view the page source because it must be sent down in a way that the web browser can interpret and display it.

                          "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                          As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                          My blog | My articles | MoXAML PowerToys | Onyx

                          K Offline
                          K Offline
                          kKamel
                          wrote on last edited by
                          #20

                          ok but how these things can be accomplished

                          P 1 Reply Last reply
                          0
                          • K kKamel

                            How??

                            I Offline
                            I Offline
                            Ian Shlasko
                            wrote on last edited by
                            #21

                            Google, and ye shall receive... http://www.codingforums.com/showpost.php?p=20367&postcount=11[^] http://www.15seconds.com/howto/pg000916.htm[^]

                            Proud to have finally moved to the A-Ark. Which one are you in? Developer, Author (Guardians of Xen)

                            1 Reply Last reply
                            0
                            • K kKamel

                              ok but how these things can be accomplished

                              P Offline
                              P Offline
                              Pete OHanlon
                              wrote on last edited by
                              #22

                              Well, not with C#, that's for a start. Shouldn't you take this over to the web development forum? You'll possibly want to ask about doing it in jquery while you're over there, or disabling the right click.

                              "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                              As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                              My blog | My articles | MoXAML PowerToys | Onyx

                              K 1 Reply Last reply
                              0
                              • P Pete OHanlon

                                Well, not with C#, that's for a start. Shouldn't you take this over to the web development forum? You'll possibly want to ask about doing it in jquery while you're over there, or disabling the right click.

                                "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                                As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                                My blog | My articles | MoXAML PowerToys | Onyx

                                K Offline
                                K Offline
                                kKamel
                                wrote on last edited by
                                #23

                                Ok thanks i will post it on the other forum thanks for helping me guys but as a last question you are saying that to do what i am asking for i should use jquery not C# code. Right?

                                P C 2 Replies Last reply
                                0
                                • K kKamel

                                  Ok thanks i will post it on the other forum thanks for helping me guys but as a last question you are saying that to do what i am asking for i should use jquery not C# code. Right?

                                  P Offline
                                  P Offline
                                  Pete OHanlon
                                  wrote on last edited by
                                  #24

                                  You need to use Javascript for this, not C#. Suppose I wanted to view your webpage on a Linux distro - how would you stop me from viewing the source there?

                                  "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                                  As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                                  My blog | My articles | MoXAML PowerToys | Onyx

                                  K 1 Reply Last reply
                                  0
                                  • P Pete OHanlon

                                    You need to use Javascript for this, not C#. Suppose I wanted to view your webpage on a Linux distro - how would you stop me from viewing the source there?

                                    "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                                    As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                                    My blog | My articles | MoXAML PowerToys | Onyx

                                    K Offline
                                    K Offline
                                    kKamel
                                    wrote on last edited by
                                    #25

                                    JavaScript it is , thanks. I will post it in the other forum.

                                    1 Reply Last reply
                                    0
                                    • K kKamel

                                      Ok Guys it seems that i used some wrong terminology , once i was working on a web application when my PM did something suddenly when i right click on view page source there was nothing related to the page source. This is what i want to implement in my new application. Hope i explained it.

                                      C Offline
                                      C Offline
                                      Christian Graus
                                      wrote on last edited by
                                      #26

                                      You're getting a lot of responses here. It seems to me that you have no idea what you're doing. 1 - right clicking on a web page lets you view the HTML, not the source code. 2 - the code your PM did to stop right clicks, is useless, anyone can defeat it 3 - there's nothing similar in a non web app, because it doesn't use HTML 4 - anyone can read your source code ( unlike a web app ), using reflection 5 - you can use free obsfucators, but free or commercial, they won't stop anyone determined 6 - you can spend a lot of money on tools that remove your source code, 7 - odds are high that it's not worth the effort.

                                      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                                      1 Reply Last reply
                                      0
                                      • K kKamel

                                        What am talking about is i do not want the client when he clicks view page source to view the javascript functions the control ids and so on...

                                        C Offline
                                        C Offline
                                        Christian Graus
                                        wrote on last edited by
                                        #27

                                        OK, so you're actually in the wrong forum ? You can't stop it. Forget about it.

                                        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                                        1 Reply Last reply
                                        0
                                        • K kKamel

                                          Ok thanks i will post it on the other forum thanks for helping me guys but as a last question you are saying that to do what i am asking for i should use jquery not C# code. Right?

                                          C Offline
                                          C Offline
                                          Christian Graus
                                          wrote on last edited by
                                          #28

                                          khalil.kamel wrote:

                                          i should use jquery not C# code

                                          Again, it's clear you are clueless. The odds of you writing code anyone would want to steal, are low. You CANNOT replace C# with jquery. Your C# code is the only thing that's secure here. It's on the server, and the user can't access it.

                                          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups