encryption - obfuscate or encrypt some plain text data in PHP -


I need to obscure or encrypt some plain text data in my PHP 5.2 application.

I want to find a solution that will keep the input string and the output string in the same length.

There is no need to be very strong, because it would be nice to empower many other layers of security, but this programmer / dba / support people / etc against reading the wrong text within the database .

The main idea

  • Adid edited I would prefer a solution where input string and output string will maintain the same length.
  • Only the string text will be encrypted / stored in the database
  • To save the php application database and read the / dencrypt database
  • this is an amendment to an existing application
  • only a few columns
  • only a few lines see only a few loads To go beyond understanding / Encrypted, a type field
  • will be required to go beyond the understanding / saving / encrypted
  • Maximum column size is already available for some areas Determined, but not for others, but I prefer a solution to work within the existing size of the limited field
  • Edit, A DD key might be some primary Key info Mr. + United States will be a combination of underlying areas

Here is a sample database table and data:

  int character (1) varchar (24) Full Date MyPrimaryKey Ro Type UserText User Non Date Change ------------ ------- -------------- -------- - -------- ---------------- 1 N Special here not 43 6/20/2009 12:11 am 2N The only thing, Wow! 78 6/23/2009 1:03 PM 3 S Fbijekejiktikjekejedblyueff 78 Dielji @ 45 kjg 43 6/25/2009 6:45 AM 4 N same old, same old stories 21 6/25/2009 8:11 am < / Code> 

The application will normally load and display rows 1,2 and 4. But it's conditional (on line type basis) it's dark / encrypted and un-dark / logic decrypt handle the text in row 3.

Can anyone provide dark / encrypted and un-dark / decrypt functions code, links, and or pointer which will help here?

Thank you!

Edit
I like the simple base 64 encoding idea, but there are methods that can keep the data within a certain size. Output value in all the methods listed so far Greater than price. This will be a problem for some columns, where the user can enter 50 characters and it is stored in a varchar (50) column.

sign in php Change in words:

  $ readable = 'This is a special test string ABC123 ([+, -! # $% & Amp; *]);'; $ Unreadable = strtr ($ readable, ' "# $% & amp; \' () * +, - / 0123456789:.? & Lt; = & gt; @ ABCDEFGHIJKLMNOPQRSTUVWXYZ [\] ^ _` abcdefghijklmnopqrstuvwxyz {|} ~ € , ƒ "... † ‡ ‰ S  œžŸ ¡¢ £ ¤ ¥ | §¨ © ª« ¬®¯ ° ± ²³'μ¶ · ¸¹º »¼½¾¿ ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ × ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö ÷ øùúûüýþÿ ',' ¡¢ £ ¤ ¥ | §¨ © ª «¬®¯ ° ± ²³'μ¶ · ¸¹º» ¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ × ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö ÷ øùúûüýþÿ "# $% & amp ;! \ '( ) * +., - / 0123456789 :; & lt; = & gt; @ ABCDEFGHIJKLMNOPQRSTUVWXYZ [\] ^ _ `ABCDEFGHIJKLMNOPQRSTUVWXYZ {|} ~ €, ƒ" ... † ‡ ‰ c  

To decode php:

< pre> $ unreadable = 'ÕéêôAêôAâAôñæäêâíAõæôõAôõóêïèAÂÃIJ³'A © ܬ® ¢ ¤ ¥ | § «Þª'; $ Readable = Strtr ($ unreadable, '¡¢ £ ¤ ¥ · ¨ · ¨ · ¯ · ¯ · ± ² · μ · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·). +, - / 0123456789:; & Lt; = & Gt; ABCDEFGHIJKLMNOPQRSTUVWXYZ @ [\] ^ _ `ABCDEFGHIJKLMNOPQRSTUVWXYZ {|} ~ €, ƒ" ... † ‡ ‰ c œžŸ ','! "# $% & Amp; \ '() * +, -. / 0123456789:; & Lt; = & Gt; @ Abiseediifjiacaijekeelmanopikyuartiuviaksaksaks [\] ^ _` Abiseedifjiaielmanpikrastwvoksij {|} ​​~ €, ƒ "... † ‡ ‰ S œžŸ ¡¢ £ ¤ ¥ | §¨ © ª« ¬ Printable readable; // output: "This is a special test string ABC123 ([+, -! # $% & Amp;; Amp; & # 39; & # 39; & # 39; & # 39;

If necessary, you can easily repeat this argument in DB (without looping):


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -