c# - Replace method doesn't replace dashes to empty string -
c# - Replace method doesn't replace dashes to empty string -
i'm trying hash file using sha1. result looks this: b7-db-b9-93-e7-2f-6f-eb-6d-cd-cc-a8-de-d2-f1-01-6e-8a-53-bc
how replace dashes empty string or remove them?
the code trying replace dashes, seems don't alter , dashes still in place.
using (hashalgorithm hashsha1 = new sha1managed()) using (stream file = new filestream(ofdbrowse.filename, filemode.open, fileaccess.read)) { byte[] hash = hashsha1.computehash(file); txtsha1.text = bitconverter.tostring(hash).replace("-", ""); }
the code you've give definitely removes dashes. short finish programme demonstrate that:
using system; using system.io; using system.security.cryptography; class test { static void main(string[] args) { using (hashalgorithm hashsha1 = new sha1managed()) { // actual info doesn't matter using (stream info = new memorystream()) { byte[] hash = hashsha1.computehash(data); console.writeline(bitconverter.tostring(hash).replace("-", "")); } } } } so, potential cause of problem:
you're not running build think are you've got other code hashing doesn't havereplace call you're looking @ wrong bit of ui :) it's hard guess of (or else) problem, code isn't it...
c# .net replace
Comments
Post a Comment