How to crypt and decrypt ?


Back to php.


thibault    (2009-04-10)

thibault

How to crypt and decrypt ?

Every programmer at least once look for a good way to encrypt with the possibility to decrypt. Md5 and Sha1 are not convenient in this case as it is not possible to decrypt with these functions.

Here are nice functions that will help you to encrypt and decrypt with a key :

<?

function encrypt($string, $key)
{
$string = 'STT576PWZA'.$string;

$result = '';
for($i=0; $i<strlen($string); $i++)
{
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)+ord($keychar));
$result.=$char;
}

return base64_encode($result);
}

function decrypt($string, $key)
{
$result = '';
$string = base64_decode($string);

for($i=0; $i<strlen($string); $i++)
{
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)-ord($keychar));
$result.=$char;
}

$result = substr($result,10,strlen($result));

return $result;
}

?>


Note that here the string to encrypt is added to 10 characters, this may not be useful but it is just a way to add kind of salt.

It works fine anyway !



(more options below)

*rotune    (2013-09-08 20:33:35)
How to crypt and decrypt ?

It's a shame you don't have a donate button! I'd most certainly donate to this outstanding blog! I suppose for now i'll settle for book-marking and adding your RSS feed to my Google account. I look forward to new updates and will talk about this website with my Facebook group. Chat soon!
lululemon outlet ht*p://www.lululemonstore.net


*sasebi    (2014-05-17 23:48:22)
10 years ago

It's a shame you don't have a donate button! I'd certainly donate to this fantastic blog! I guess for now i'll settle for book-marking and adding your RSS feed to my Google account. I look forward to fresh updates and will talk about this blog with my Facebook group. Talk soon!
cheap beats by dr dre


See also


ficgs
More websites

You must register to see these links, as this is a collaborative page, then you may change the order of the links by clicking the icons before the titles.



admin
Other websites

The following links might be less relevant, please change their ranks if you find them useful.


 Crypt decrypt password [Archive] - CodingForums.com
codingforums > archive/index.php/t 80996
  1. Is there a way to encrypt records before inserting them into the
  2. While its true that MD5 cannot be decrypted - it can be
 I need crypt and decrypt basic sample - ASP.NET Security
justskins > forums/i need crypt and decrypt basic sample 37506

 Projects tagged ‘crypt’ and ‘decryption’ - Ohloh
ohloh > tags/crypt/decryption

Failing to fetch: enlistment of a repo belonging to a...
Hey guys, First...

 crypt and decrypt IP address for a php project
mail.python > pipermail/python list/2004 June/264805

 Delphi tip#172: to crypt/decrypt the file using Crypt API
scalabium > faq/dct0172.htm

 crypt -- encryption/decryption filter
mkssoftware > docs/man1/crypt.1.asp

MKS Toolkit for Power Users MKS Toolkit for System Administrators...
encrypts the input using the National Bureau of Standards' Data...

 FULL POSTER SNIPS: Javascript Make A Tabula Recta Matrix. Crypt And Decrypt With Vigenere Cipher (Programming Javascript)
fullposter > snippets.php?snippet=112

 crypt and decrypt IP address for a php project
velocityreviews > forums/t331615 crypt and decrypt ip address for a php project

but in order to trick spammers into revealing their IP addresses...
It's easy, and the base64 routines should be compatible (that's...

 crypt and decrypt a string - ObjectMix Forum
objectmix > php/440524 crypt decrypt string

Subject: [PHP] crypt and decrypt a string Does anybody have an...
an encryption class ===== *********************************...
Here are some simple xor encoding functions that I...

 » Free Crypt decrypt php script
findmysoft > scripts/crypt decrypt php script

Short keys Rivest-Shamir-Adelman (RSA) encrypt-decrypt functions...

 Download Cryptofile 1.0 for PalmOS - Cryptofile - Crypt and decrypt file on external cards (m500, 505). - Softpedia
handheld.softpedia > get/Security/Encryption/Cryptofile 38451.shtml

 Download Crypt & Decrypt zip for free at Uploading.com
uploading > files/QF6UOVPM/Crypt

Devenez premium immédiatement, facilement et en toute...
30) set_notification('alert', 'Cookies seem to be disabled in...

 Xor for decrypt/crypt in 6 lignes - GSM-Forum
forum.gsmhosting > vbb/s

 Decrypt Files - Take care of your security!! digitally sign, crypt and decrypt your files The quick encryption and decryption files of any type
filesland > companies/FileEncryption org/decrypt files

 Free kriptirnik file crypt akte krypta protect encrypt decrypt Download - kriptirnik file crypt akte krypta protect encrypt decrypt Software
wareseeker > free kriptirnik file crypt akte krypta protect encrypt decrypt

var pageOptions = { 'pubId' : 'pub-8098918000470057', 'channel' :...
Other version of Flexcrypt -Encrypt your data now...

 Perl Guru Forums: Perl Programming Help: Beginner: Can not Crypt::RSA->decrypt... :(
perlguru > gforum.cgi?post=32678;guest=3735055

 File Decrypt Soft: WinXAR, Stealth Files, MEO File Encryption Software, File Crypt, ...
softplatz > software/file decrypt

Encryption software to encrypt or decrypt files...
The ultimate Tool for packing, encrypting and hiding...

 OraFAQ Forum: SQL & PL/SQL => Crypt and Decrypt Fileds
orafaq > forum/t/72247/0

CREATE OR REPLACE PACKAGE user_security AS FUNCTION encrypt...
This is the PL-SQL Procedure I created, but it dooesn't work...

 New Crypt & Decrypt - Sat-Television.com - Satellite Encryption
sat television > s

 Crypt - Decrypt AES Formular
stermon > temp/aes/crypt decrypt form.htm

 Crypt some text and Decrypt it : Crypt, Decrypt
experts exchange > Programming/Languages/.NET/Visual CSharp/Q 24175268

 File Crypt - File Crypt is freeware program for file protect. File Crypt encrypt/decrypt file with strong encryption.
sharewareconnection > file crypt.htm

GUIPDFTK - merge, split, decrypt, crypt, re-compress, decompress...
A small and easy to use file encryption utility that enables you to...

 Encryption / decryption programs
garbo.uwasa > pc/crypt

15770 Jan 5 1993 File or directory tree encryption utility using...
2024 Sep 17 19:23 Descriptions of the files in the crypt directory...
293121 Apr 19 1994 Documentation to SFS100 in LaTeX- and ps-format...

 File Crypt - Free software downloads and reviews - CNET Download.com
download.cnet > File Crypt/3000 2092 4 10702911

CNET TechTracker will attempt to install this software without...

 l-crypt.el --- cmail with mailcrypt 3.4 or later ;;; ;;; Copyright (C) 1997 Toshihiko Ueki ;;; ;;; Author: Toshihiko Ueki ;;; Created: 1997/04/...
cvs.sourceforge > cgi bin/viewcvs.cgi/cmail/src/cmail crypt.el?view=co

 Download Decryption Software: File Crypt, Polar Crypto Light Free, CommuniCrypt Mail, ...
filebuzz > files/decryption/2

 ASPN : Crypt::ECB 1.1
aspn.activestate > ASPN/CodeDoc/Crypt ECB/ECB

 ::CBC; use MD5; use Carp; use strict; use vars qw($VERSION); $VERSION = '1.32'; sub new ($$;$) { my $class = shift; my ($key,$ciph...
zoneedit > doc/partner/Crypt/CBC.pm

 Crypt / Decrypt .NET configuration files - Vista Forums
vistax64 > powershell/103289 crypt decrypt net configuration files

Cannot decrypt files when copying them to another...
Vista Forums is an independent web site and has not been...

 crypt.xhead Resources | TechRepublic
search.techrepublic.com > search/crypt.xhead

Apps QuickStart Series Part 1: Designing and Deploying Exchange 2010...
Achieving New Productivity Gains Through Unified Communications and...
Hang up on your PBX and gain significant savings, 0 percent...

 Nabble - OpenSC - User - Question about extract_key() function in pkcs15-crypt.c
nabble > Question about extract key() function in pkcs15 crypt.c td20933718

 Download Decrypt File Software: Stealth Files, Dekart Secrets Keeper, File Crypt, PDF Password Recovery COM SDK
bluechillies > list/decrypt file

PDF Password Recovery and PDF Password Remover COM...



Response  
 

Guest name   (option)     Register
Please sum : 2324 + one  




Trackbacks : If you talked about this article in your blog or website, you may instantly get a backlink 
There's no trackback at the moment.