Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

hash password with salt c#

public class CryptographyProcessor
{
    public string CreateSalt(int size)
    {
        //Generate a cryptographic random number.
        RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
        byte[] buff = new byte[size];
        rng.GetBytes(buff);
        return Convert.ToBase64String(buff);
    }

    public string GenerateHash(string input, string salt)
    { 
        byte[] bytes = Encoding.UTF8.GetBytes(input + salt);
        SHA256Managed sHA256ManagedString = new SHA256Managed();
        byte[] hash = sHA256ManagedString.ComputeHash(bytes);
        return Convert.ToBase64String(hash);
    }

    public bool AreEqual(string plainTextInput, string hashedInput, string salt)
    {
        string newHashedPin = GenerateHash(plainTextInput, salt);
        return newHashedPin.Equals(hashedInput); 
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to check if textbox is empty in c# 
Csharp :: delayed function unity 
Csharp :: how to convert from hexadecimal to binary in c# 
Csharp :: T SQL Format GetDate() 
Csharp :: remove carriage returns from string c# 
Csharp :: cs entity framework 
Csharp :: unity change particle system sorting layer via script 
Csharp :: c# get class name by type 
Csharp :: Compare trees 
Csharp :: c# list append 
Csharp :: how to close and reopen an app in c# 
Csharp :: if char is upper csharp 
Csharp :: c# string default value 
Csharp :: c# hello world 
Csharp :: unity position localposition 
Csharp :: new line console c# 
Csharp :: How do i destroy a prefab without the error? 
Csharp :: convert json to list object c# 
Csharp :: c# get enum value from string 
Csharp :: make folder with c# 
Csharp :: how set function when props update in vue 
Csharp :: return json from controller c# 
Csharp :: convert string into double in c# 
Csharp :: xamarin hide back button 
Csharp :: log to console c# unity 
Csharp :: c# list string return concatenate 
Csharp :: get enum value from display name c# 
Csharp :: unity pick random number 
Csharp :: Install Mono project on Ubuntu 20.04 
Csharp :: unity cap fps 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =