Skip to content

Cihat-Girgin/C-Sharp-ComputeHash-JS-Equivalent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

C-Sharp-ComputeHash-JS-Equivalent

Equivalent version of SHA256 ComputeHash (from C#) for JavaScript

One of the following pieces of code is written in c# and the other in javascript. If the inputs are the same, the outputs are the same.

.Net(C#)

  System.Security.Cryptography.SHA1 sha = new System.Security.Cryptography.SHA1CryptoServiceProvider();
            byte[] bytes = System.Text.Encoding.ASCII.GetBytes(str);
            byte[] hashingbytes = sha.ComputeHash(bytes);
            var hash = Convert.ToBase64String(hashingbytes);
            

JavaScript

getHash = str =>{
        const hashingBytes = Buffer.from(sha1(str), "hex");
        const base64Value = Buffer.from(hashingBytes).toString('base64');
        return base64Value;
    }

About

Equivalent version of SHA256 ComputeHash (from C#) for JavaScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published