-1

I am wondering if there is a better way to create my very own encryption. I have looked up some tips on youtube and I found str_replace. When I tested it, I found out that you could just do. It is also not easy to decode.

Input:A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Output:1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P 0

Is there a better way to do this but instead with math and it can still be decoded. For instance, with math, if I were to do the above it would do something else like this:

Input:A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Output:A4D1G3F4G5H1A4G2F8GFGDFGRH2352GDGHH435DGFDH436DFHH

I already have tried str_replace, md5, sha1, and rot13.

  • 6
    best NOT to try to build this your self. http://stackoverflow.com/questions/9262109/php-simplest-two-way-encryption –  Jul 10 '15 at 01:17
  • 3
    Encryption is an incredibly complicated and advanced topic. It would take a handful of books to fully explain it. Unless you are studying it, and have people around you to check your work, you should not create your own encryption algorithms. – Sverri M. Olsen Jul 10 '15 at 01:19
  • BTW- your example is quite close to the common rot13() if you did not know that already http://php.net/manual/en/function.str-rot13.php. old\bad joke "my rot13 encoder works by my decoder is broken" –  Jul 10 '15 at 01:20
  • 2
    All forms of encryption depend on a secret key of some kind. Anything that's just a simple algorithm with no key can be decoded just by knowing the algorithm. – Barmar Jul 10 '15 at 01:25
  • Crypto is awesome! Unfortunately, modern crypto relies very heavily on some ridiculously crazy and *extremely finicky* math that most programmers just can't really manage. It's hard enough *implementing* an existing algorithm without making 17 boneheaded errors that leave gaping holes for a competent attacker, but *designing* your own genuinely effective crypto algorithm is something only maybe a few thousand people in the world are capable of, at most. I am not one of them, and I don't expect you to be either. – Nathan Tuggy Jul 10 '15 at 01:30

1 Answers1

1

You don't want to do this, other than for self-education. A good place to start and gain some practical understanding of how cryptography works in software is the Matasano crypto challenges which you can find at:

http://cryptopals.com

pvg
  • 2,673
  • 4
  • 17
  • 31
  • Great website, but it's not what I am looking for. Thank You for the resource. – Thomas Wilbur Jul 10 '15 at 01:34
  • 1
    Read Bruce Schneier's [advice to the Amateur Cipher Designer](https://www.schneier.com/crypto-gram/archives/1998/1015.html#cipherdesign). By all means study, play and learn. Any cipher you design will be insecure. At best it will stop your kid sister reading your stuff (unless she works for the NSA). A simple cipher to study is [RC4](https://en.wikipedia.org/wiki/RC4), so it might be useful for you to have a look at that. – rossum Jul 10 '15 at 10:19