amaru Posted July 5, 2011 Share Posted July 5, 2011 I use this function to encrypt passwords. I can't use md5 because i use the passwords in a sa-mp server. function cryptpw($password) { for($i=0; $i < strlen($password); $i++) { $temp = ord($password[$i]); $temp += (3^$i) * ($i % 15); if($temp > (0xff)) { $temp -= 256; } $password[$i] = chr($temp); } return $password; } It encrypts the password but it puts some signs at the end of it like '}' or '�'. How can i remove them? Link to comment https://forums.phpfreaks.com/topic/241125-encrypt-problem/ Share on other sites More sharing options...
TeNDoLLA Posted July 5, 2011 Share Posted July 5, 2011 Fix your character set. Link to comment https://forums.phpfreaks.com/topic/241125-encrypt-problem/#findComment-1238490 Share on other sites More sharing options...
amaru Posted July 5, 2011 Author Share Posted July 5, 2011 I know the bases of php. This function is took from a ucp. How can i do it? Link to comment https://forums.phpfreaks.com/topic/241125-encrypt-problem/#findComment-1238502 Share on other sites More sharing options...
TeNDoLLA Posted July 5, 2011 Share Posted July 5, 2011 Uhm.. ucp what? Link to comment https://forums.phpfreaks.com/topic/241125-encrypt-problem/#findComment-1238511 Share on other sites More sharing options...
amaru Posted July 5, 2011 Author Share Posted July 5, 2011 user control panel Link to comment https://forums.phpfreaks.com/topic/241125-encrypt-problem/#findComment-1238514 Share on other sites More sharing options...
TeNDoLLA Posted July 5, 2011 Share Posted July 5, 2011 Try this what is the output echo mb_convert_encoding($crypted_password, 'UTF-8'); Also what is sa-mp server? I still think this is a character encoding problem, either in your browser settings, php, or html. Or combination of these. Link to comment https://forums.phpfreaks.com/topic/241125-encrypt-problem/#findComment-1238517 Share on other sites More sharing options...
amaru Posted July 5, 2011 Author Share Posted July 5, 2011 The last character is "Â" Link to comment https://forums.phpfreaks.com/topic/241125-encrypt-problem/#findComment-1238565 Share on other sites More sharing options...
btherl Posted July 6, 2011 Share Posted July 6, 2011 It depends on what exactly you want, but you could try using base64_encode() on the result of your encryption. Also I might rethink your calculation for the value to add - for many values of $i it has little or no effect, and it is very predictable. Link to comment https://forums.phpfreaks.com/topic/241125-encrypt-problem/#findComment-1238764 Share on other sites More sharing options...
newb Posted July 6, 2011 Share Posted July 6, 2011 try the mb_convert_encoding function and post back let me know what happens Link to comment https://forums.phpfreaks.com/topic/241125-encrypt-problem/#findComment-1238796 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.