I'm going to run SHA256 on a password + salt, but I don't know how long to make my VARCHAR when setting up the mysql database. What is a good length?
I have been trying to convert a C# encryption technique to PHP. The C# code is as given below. I have no experience in C#. I had to take over project in C#
private void button1_Click(object sender, EventArgs e){ //byte[] response = ComputeHash("pradeep14520", BitConverter.GetBytes("0x9A111B734E4F10469668")); //byte[] response = ComputeHash("pradeep14520", dictionary.ElementAt(0).Value.Salt); byte[] response =ComputeHash("pradeep14520", StringToByteArray("9A111B734E4F10469668")); string hex = BitConverter.ToString(response).Replace("-", string.Empty); string base64 = Convert.ToBase64String(response); // 683CA8E00E8CE41A079B7C86CE4960AC2376CD85F2AEAB2E4DF99FFA7F7FA4F3} private byte[] ComputeHash(string password, byte[] storedSalt) { byte[] passwordBytes = Encoding.Unicode.GetBytes(password); if ((int)storedSalt.Length > 0) { byte[] passwordAndSalt = new byte[(int)passwordBytes.Length + (int)storedSalt.Length]; passwordBytes.CopyTo(passwordAndSalt, 0); storedSalt.CopyTo(passwordAndSalt, (int)passwordBytes.Length); passwordBytes = passwordAndSalt; } return new SHA256Managed().ComputeHash(passwordBytes); }I have commented the sample response in the button click function. I tried to implement the same functionality using PHP. with the below code after referring this link
.I have found that there is no need to produce byte arrays in PHP as strings are byte arrays in php.
$originalSalt = 'pradeep14520'; $originalSalt .= '9A111B734E4F10469668'; hash("sha256",iconv(mb_detect_encoding($originalSalt, mb_detect_order(), false), "UTF-8", $originalSalt),true);I have passed the last argument to the hash function as false inorder to get raw output.But i am getting different Output for PHP and C#
for PHP :afc80d1a6cae81e8f868b054dafbb74bdd86399d771fceef574e4b373506b704for C# :683CA8E00E8CE41A079B7C86CE4960AC2376CD85F2AEAB2E4DF99FFA7F7FA4F3Plz help.Thanks in advance.
Based on the suggestion provided by Daniel Hilgarth i have modified the code and made it work.
$password = 'pradeep14520';$originalSalt = hex2bin('9A111B734E4F10469668');echo strtoupper(hash("sha256",mb_convert_encoding($password,"UTF-16LE").$originalSalt,false));I hope it will help someone..
I am currently using SHA256 with a salt to hash my passwords. Is it better to continue using SHA256 or should I change to SHA512?
Currently I'm designing a hashing system for user emails, but what happens if the user email is longer than the hash output. I usually use sha1 sha256 or sha512 if it makes a difference based on algorithm... It just seems like at a point the algorithm wouldn't be able to keep on producing unique outputs.
I'm trying to create unique file names by renaming them using their hashed value in iOS. How can I do that?
Casa - Mapa del sitio - Intimidad - Enlaces - Copyright © 2013 Cortex IT Ltd : Contacto : admin @ cortexit.co.uk
Please note that by viewing our site you agree to our use of cookies (see Intimidad for details). You will only see this message once.