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. Other Discussions
  3. The Weird and The Wonderful
  4. Secure enrcyption function

Secure enrcyption function

Scheduled Pinned Locked Moved The Weird and The Wonderful
security
9 Posts 9 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.
  • O Offline
    O Offline
    o m n i
    wrote on last edited by
    #1

    Found this great code for encryption in our codebase. All of the client's extremely sensitive information is being stored locally using this.

    string Encryption::EncryptString(string dat) {
    string n = "qwertyuiopasdfghjklzxcvbnm"
    n += n + n + n + n; //keeps the full string from appearing in string table
    for (size_t i = 0; i < dat.size(); i++) {
    dat[i] ^= n[i];
    }
    return dat;
    }

    And it gets even better when you see the decrypt function:

    string Encryption::DecryptString(string dat) {
    return EncryptString(dat); //xor is reversible
    }

    I I F B M 7 Replies Last reply
    0
    • O o m n i

      Found this great code for encryption in our codebase. All of the client's extremely sensitive information is being stored locally using this.

      string Encryption::EncryptString(string dat) {
      string n = "qwertyuiopasdfghjklzxcvbnm"
      n += n + n + n + n; //keeps the full string from appearing in string table
      for (size_t i = 0; i < dat.size(); i++) {
      dat[i] ^= n[i];
      }
      return dat;
      }

      And it gets even better when you see the decrypt function:

      string Encryption::DecryptString(string dat) {
      return EncryptString(dat); //xor is reversible
      }

      I Offline
      I Offline
      Ibrahim Yusuf
      wrote on last edited by
      #2

      Superb. Microsoft should remove the System.Security.Cryptography as soon as possible. ;P

      1 Reply Last reply
      0
      • O o m n i

        Found this great code for encryption in our codebase. All of the client's extremely sensitive information is being stored locally using this.

        string Encryption::EncryptString(string dat) {
        string n = "qwertyuiopasdfghjklzxcvbnm"
        n += n + n + n + n; //keeps the full string from appearing in string table
        for (size_t i = 0; i < dat.size(); i++) {
        dat[i] ^= n[i];
        }
        return dat;
        }

        And it gets even better when you see the decrypt function:

        string Encryption::DecryptString(string dat) {
        return EncryptString(dat); //xor is reversible
        }

        I Offline
        I Offline
        imagiro
        wrote on last edited by
        #3

        Question: I use another keyboard layout. Will it still work? However, this is a good encryption function - only the first 130 chars will be encrypted with a known key...

        1 Reply Last reply
        0
        • O o m n i

          Found this great code for encryption in our codebase. All of the client's extremely sensitive information is being stored locally using this.

          string Encryption::EncryptString(string dat) {
          string n = "qwertyuiopasdfghjklzxcvbnm"
          n += n + n + n + n; //keeps the full string from appearing in string table
          for (size_t i = 0; i < dat.size(); i++) {
          dat[i] ^= n[i];
          }
          return dat;
          }

          And it gets even better when you see the decrypt function:

          string Encryption::DecryptString(string dat) {
          return EncryptString(dat); //xor is reversible
          }

          F Offline
          F Offline
          fjdiewornncalwe
          wrote on last edited by
          #4

          Oh Horror of Horrors... This one is certainly one of the best. I don't think it could have been any worse if it had been written in vbscript.

          I wasn't, now I am, then I won't be anymore.

          1 Reply Last reply
          0
          • O o m n i

            Found this great code for encryption in our codebase. All of the client's extremely sensitive information is being stored locally using this.

            string Encryption::EncryptString(string dat) {
            string n = "qwertyuiopasdfghjklzxcvbnm"
            n += n + n + n + n; //keeps the full string from appearing in string table
            for (size_t i = 0; i < dat.size(); i++) {
            dat[i] ^= n[i];
            }
            return dat;
            }

            And it gets even better when you see the decrypt function:

            string Encryption::DecryptString(string dat) {
            return EncryptString(dat); //xor is reversible
            }

            B Offline
            B Offline
            BillW33
            wrote on last edited by
            #5

            That is a truly brilliant encryption strategy, I will have to use it the next time I need such a thing. X|

            Just because the code works, it doesn't mean that it is good code.

            1 Reply Last reply
            0
            • O o m n i

              Found this great code for encryption in our codebase. All of the client's extremely sensitive information is being stored locally using this.

              string Encryption::EncryptString(string dat) {
              string n = "qwertyuiopasdfghjklzxcvbnm"
              n += n + n + n + n; //keeps the full string from appearing in string table
              for (size_t i = 0; i < dat.size(); i++) {
              dat[i] ^= n[i];
              }
              return dat;
              }

              And it gets even better when you see the decrypt function:

              string Encryption::DecryptString(string dat) {
              return EncryptString(dat); //xor is reversible
              }

              M Offline
              M Offline
              musefan
              wrote on last edited by
              #6

              I have tried your suggestion for encrypting and decrypting but it keeps giving me errors when I try to play the code. I really need this to work ASAP as it is a very important project for me!!!

              return 5;

              L 1 Reply Last reply
              0
              • M musefan

                I have tried your suggestion for encrypting and decrypting but it keeps giving me errors when I try to play the code. I really need this to work ASAP as it is a very important project for me!!!

                return 5;

                L Offline
                L Offline
                Lutoslaw
                wrote on last edited by
                #7

                It looks like some urgentz univoters didn't get it. :rolleyes: PS. I had considered voting you up but I found these two uni-votes funnier than the content. Sorry ;P

                Greetings - Jacek

                1 Reply Last reply
                0
                • O o m n i

                  Found this great code for encryption in our codebase. All of the client's extremely sensitive information is being stored locally using this.

                  string Encryption::EncryptString(string dat) {
                  string n = "qwertyuiopasdfghjklzxcvbnm"
                  n += n + n + n + n; //keeps the full string from appearing in string table
                  for (size_t i = 0; i < dat.size(); i++) {
                  dat[i] ^= n[i];
                  }
                  return dat;
                  }

                  And it gets even better when you see the decrypt function:

                  string Encryption::DecryptString(string dat) {
                  return EncryptString(dat); //xor is reversible
                  }

                  J Offline
                  J Offline
                  Jorgen Sigvardsson
                  wrote on last edited by
                  #8

                  As long as you hide the key well, and use it only once... :D

                  -- Kein Mitleid Für Die Mehrheit

                  1 Reply Last reply
                  0
                  • O o m n i

                    Found this great code for encryption in our codebase. All of the client's extremely sensitive information is being stored locally using this.

                    string Encryption::EncryptString(string dat) {
                    string n = "qwertyuiopasdfghjklzxcvbnm"
                    n += n + n + n + n; //keeps the full string from appearing in string table
                    for (size_t i = 0; i < dat.size(); i++) {
                    dat[i] ^= n[i];
                    }
                    return dat;
                    }

                    And it gets even better when you see the decrypt function:

                    string Encryption::DecryptString(string dat) {
                    return EncryptString(dat); //xor is reversible
                    }

                    V Offline
                    V Offline
                    Vladimir Svyatski
                    wrote on last edited by
                    #9

                    You know, this function is so great that it will crash the application if "dat" is long enough (longer than 130 symbols).

                    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