Click here to Skip to main content
15,902,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi! My question is probably very simple, but I need to ask.

I encoded my string with password_hash in my PHP page, but now I need to encode a string in my C# Windows Forms Application.

For example, "garchomp9" would be equal to "$2y$10$opiDs.kbUEN6HUPzYCHyX.cOVQt5BvWrqWMrSkXHlP7d91.9aERfK"

Any help?

What I have tried:

Sadly, I have deleted my code accidentally.(My PC got shut off..)
Posted
Updated 8-Feb-20 18:08pm

PHP: password_hash - Manual[^]

Use BCrypt to Hash Your Passwords: Example for C# and SQL Server[^]

The first link allows to state that default password hash algorithm is bcrypt.

The second link is an article on CP which deals with the subject.
 
Share this answer
 
Comments
The Magical Magikarp 9-Feb-20 4:21am    
Thanks, just what I needed :)
phil.o 9-Feb-20 4:32am    
You're welcome!
Quote:
I encoded my string with password_hash in my PHP page, but now I need to encode a string in my C# Windows Forms Application.

Short answer: You don't decode a hash because it is not reversible.
A hash is not encryption, hash is specially designed to prevent 'unhashing'.
Hash function - Wikipedia[^]

As stated in php manual, the php feature can change over time.
If you want same hashing over php and C#, you need to choose a hashing algorithm/library that will be available in both languages.
Quote:
Sadly, I have deleted my code accidentally.(My PC got shut off..)

Serious programmers are loosing their time doing useless backups because 1 day, the useless backup turns to invaluable.
Backup - Wikipedia[^]
Version control - Wikipedia[^]
 
Share this answer
 
v4
Comments
phil.o 9-Feb-20 0:12am    
"I need to encode a string in my C# Windows Forms Application."
Where is he talking about decoding?
Patrice T 9-Feb-20 0:24am    
May be I was a little too fast. :)
phil.o 9-Feb-20 0:27am    
:)
The Magical Magikarp 9-Feb-20 1:46am    
Well, is there a library that will provide the same output as password_hash, or is that a php-exclusive function?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900