can I use sha1,sha256 lib generated string as a hash key

Anthony

I'm looking for a way to create a hash key based on a few string properties of a class. I was thinking I could use the sha1 or sha256 libs to generate the value for the key. But I'm wondering if I store that value in the DB will another app or different machine or different versions .net and .netcore be able to generate the same hash given the same string properties? A simple example of generating the hash bellow:

 public class Lead
{
    public Lead(string firstname, string lastname, string phoneNumber)
    {
        this.firstname = firstname;
        this.lastname = lastname;
        phonenumber = phoneNumber;
        this.hash = GetHash($"{firstname}{lastname}{phoneNumber}");
    }

    private string GetHash(string key)
    {
        using var sha = new System.Security.Cryptography.SHA256Managed();
        byte[] textData = System.Text.Encoding.UTF8.GetBytes(key);
        byte[] hash = sha.ComputeHash(textData);
        return BitConverter.ToString(hash).Replace("-", string.Empty);
    }
    public string firstname;
    public string lastname;
    public string phonenumber;
    public string hash;
}
Anthony

The answer is yes, I was also able to encrypt in .net and for kicks decrypt the value in rails.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I hash a string with SHA256 in JS?

SAML Token: Why use multiple Hash/Digest Algorithms: sha256 and sha1?

How do I specify the key for computing a SHA256 hash?

How can I check a sha256 hash?

How can I get the sha1 hash of a string in node.js?

How can I calculate the SHA-256 hash of a string in Android?

Can i use MD5(String)+SHA1(String) for uniqueid? (ASCII Only)

sha256 hash from public key

How to use sha256 hash in Python

How can I replicate a javascript sha256 hash in Java and get the same Hex output?

Crystal: How can I find the SHA256 hash of a binary value?

Compiled sha256 lib for mysql but it produces other hash than dovecot's sha256

Is it possible to check if a hash was generated using SHA1 and is a valid hash?

Hex form for a sha1 hash of a String?

Generate HMAC SHA256 hash using key in C++

How can I rewrite password hash made by SHA1(in ASP.NET Identity)?

Library providing various hash algorithms (MD5, SHA1, SHA256, etc) in Java?

“Hash sum mismatch” error due to identical SHA1 and MD5 but different SHA256

Generating md5/sha1/sha256 hash of downloaded file in Chrome Extension

java - is there a way to confirm that a string is a sha256 hash?

How to hash some string with sha256 in Java?

Get SHA256 hash of UTF-16le String

how to use a SHA256 hash in Hex format in laravel

Can I use an SSH key generated on Linux from Putty?

How Do I Convert a Picture into a Sha256 Hash Python

Hmac with SHa256 Or SHa256 with key appended in the input string? Which is more secure?

In Perl 6, can I use an Array as a Hash key?

In the future, can I use the new hash syntax with array as key?

How can I compute a SHA-2 (ideally SHA 256 or SHA 512) hash in iOS?

TOP Ranking

HotTag

Archive