mega77 Posted December 22, 2007 Share Posted December 22, 2007 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/82810-solved-function-to-use-to-encrypt-decrypt-strings/ Share on other sites More sharing options...
rarebit Posted December 22, 2007 Share Posted December 22, 2007 * base64encode is a code, not encryption, see this. * crc32 is a checksum, see this. What algorithm and mode did you use with mcrypt, there's lot's to choose from, see this. Quote Link to comment https://forums.phpfreaks.com/topic/82810-solved-function-to-use-to-encrypt-decrypt-strings/#findComment-421179 Share on other sites More sharing options...
mega77 Posted December 22, 2007 Author Share Posted December 22, 2007 I tried all the ones that my server allows in all modes but they seem to be all more or less 100 chars long. Isn't there any that result in about 15 chars or something ? Quote Link to comment https://forums.phpfreaks.com/topic/82810-solved-function-to-use-to-encrypt-decrypt-strings/#findComment-421198 Share on other sites More sharing options...
Orio Posted December 22, 2007 Share Posted December 22, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/82810-solved-function-to-use-to-encrypt-decrypt-strings/#findComment-421209 Share on other sites More sharing options...
mega77 Posted December 22, 2007 Author Share Posted December 22, 2007 I had a look at str_rot13 but my string has commas and numbers. Is there any other out there ? Quote Link to comment https://forums.phpfreaks.com/topic/82810-solved-function-to-use-to-encrypt-decrypt-strings/#findComment-421343 Share on other sites More sharing options...
Orio Posted December 23, 2007 Share Posted December 23, 2007 You can use the Vigenere cipher. Orio. Quote Link to comment https://forums.phpfreaks.com/topic/82810-solved-function-to-use-to-encrypt-decrypt-strings/#findComment-421705 Share on other sites More sharing options...
mega77 Posted December 31, 2007 Author Share Posted December 31, 2007 Thank you for your input. Unfortunately, Vigenere's cipher is surprisingly simple to crack when you know the input and the result unlike hashes. I'll find something else. Quote Link to comment https://forums.phpfreaks.com/topic/82810-solved-function-to-use-to-encrypt-decrypt-strings/#findComment-426757 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.