Jump to content

[SOLVED] function to use to encrypt & decrypt strings


Recommended Posts

I'm trying to find some function to encrypt & decrypt strings. The security level of the function is not a problem, even a very low security function is ok for my purpose. The string length that I need to encrypt would be between 45 to 60 chars.

 

- Mcrypt encrypts/decrypts strings but the results are 100 or so char long, which is far too long for my needs.

 

- base64encode is also too long.

 

- The ideal would be a crc32-like function (the resulting length is small, perfect) but unfortunately it cannot be decrypted.

 

Can anybody direct me to a small function that can encrypt and decrypt ?

If you want something "very low security" as you've defined, you can go for something simple as:

 

<?php
function code ($str)
{
return str_rot13(strrev($str));
}
?>

 

This is very very simple... You can use this function to both decode and encode the string.

 

Orio.

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.