soffes/Crypto

Doubt : How to get sha1 of Data as a String

Closed this issue · 4 comments

Right now we have methods which gives sha1 of Data as Data. So I have tried converting it into String by UTF8 Encoding & also ASCII, but it seems that both didn't produce the proper String.

How can I get sha1 as String for Data?

Internally, I convert Data to a hex string with this.

Does that work for you? I can make a public version of the Data to String when I get time.

Look at the source for the String one. It converts the string to Data, calls sha1 on the Data, and then calls hex on the Data to convert it back to a string.

I am kind of confused here, Sorry.

let dataObject = Data()
let stringHEX = dataObject.hex
let sha1 = stringHEX.sha1

You meant this right?

No.

calls sha1 on the Data, and then calls hex on the Data to convert it back to a string