sha256

Get a file SHA256 Hash code and Checksum

 ̄綄美尐妖づ 提交于 2019-12-18 08:20:32
问题 Previously I asked a question about combining SHA1+MD5 but after that I understand calculating SHA1 and then MD5 of a lagrge file is not that faster than SHA256. In my case a 4.6 GB file takes about 10 mins with the default implementation SHA256 with (C# MONO) in a Linux system. public static string GetChecksum(string file) { using (FileStream stream = File.OpenRead(file)) { var sha = new SHA256Managed(); byte[] checksum = sha.ComputeHash(stream); return BitConverter.ToString(checksum)

SHA256 signing stops working in .NET 4.5

那年仲夏 提交于 2019-12-18 04:33:10
问题 We have a piece of code which creates a SigningCredentials object to use to sign xml document by using SHA256 algorithm. It works with .NET 3.5 perfectly. However, when we upgrade our codebase to .NET 4.5, it stops working. Same code, same certificate! I have spent hours on debugging and searching on the internet without any luck. Could anyone please tell me what the problem here is? Thank you in advance. Code to create SigningCredentials: public SigningCredentials CreateSigningCredentials

How do I create a hash of a file on iOS?

和自甴很熟 提交于 2019-12-18 03:39:38
问题 I'm trying to create unique file names by renaming them using their hashed value in iOS. How can I do that? 回答1: you could achieve this by extending NSString, Try this in your .h: @interface NSString(MD5) - (NSString *)generateMD5Hash @end and this in your .m - (NSString*)generateMD5Hash { const char *string = [self UTF8String]; unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH]; CC_MD5(string, strlen(string), md5Buffer); NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST

Google OAuth2 Service Account Access Token Request gives 'Invalid Request' Response

▼魔方 西西 提交于 2019-12-17 16:10:09
问题 I'm trying to communicate with my app's enabled BigQuery API via the server to server method. I've ticked all the boxes on this Google guide for constructing my JWT as best I can in C#. And I've Base64Url encoded everything that was necessary. However, the only response I get from google is a 400 Bad Request "error" : "invalid_request" I've made sure of all of the following from these other SO questions: The signature is properly encrypted using RSA and SHA256 I am using POST and using

Java SHA256 outputs different hash to PHP SHA256?

孤街醉人 提交于 2019-12-17 09:42:24
问题 PHP code: echo hash('sha256', 'jake'); PHP output: cdf30c6b345276278bedc7bcedd9d5582f5b8e0c1dd858f46ef4ea231f92731d Java code: String s = "jake"; MessageDigest md = MessageDigest.getInstance("SHA-256"); md.update(s.getBytes(Charset.forName("UTF-8"))); byte[] hashed = md.digest(); String s2 = ""; for (byte b : hashed) { s2 += b; } System.out.println(s2); Java output: -51-1312107528211839-117-19-57-68-19-39-43884791-1141229-4088-12110-12-223531-11011529 I had expected the two to return the same

Generate sha256 with OpenSSL and C++

纵饮孤独 提交于 2019-12-17 05:40:18
问题 I'm looking to create a hash with sha256 using openssl and C++. I know there's a similar post at Generate SHA hash in C++ using OpenSSL library, but I'm looking to specifically create sha256. UPDATE: Seems to be a problem with the include paths. It can't find any OpenSSL functions even though I included #include "openssl/sha.h" and I included the paths in my build -I/opt/ssl/include/ -L/opt/ssl/lib/ -lcrypto 回答1: Here's how I did it: void sha256_hash_string (unsigned char hash[SHA256_DIGEST

Hash String via SHA-256 in Java

丶灬走出姿态 提交于 2019-12-17 03:24:08
问题 By looking around here as well as the internet in general, I have found Bouncy Castle. I want to use Bouncy Castle (or some other freely available utility) to generate a SHA-256 Hash of a String in Java. Looking at their documentation I can't seem to find any good examples of what I want to do. Can anybody here help me out? 回答1: To hash a string, use the built-in MessageDigest class: import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.nio.charset

Why are the RSA-SHA256 signatures I generate with OpenSSL and Java different?

北城以北 提交于 2019-12-17 02:29:26
问题 I want to generate a RSA-SHA256 signature in Java, but I can't get it to produce the same signature as with OpenSSL on the console. This is what I did with OpenSSL (following this tutorial): Generate key pair: openssl genrsa -out private.pem 1024 Extract public key: openssl rsa -in private.pem -out public.pem -outform PEM -pubout Create hash of data: echo 'data to sign' > data.txt openssl dgst -sha256 < data.txt > hash The generated hash file starts with (stdin)= what I removed by hand (first

SHA256 in swift

我只是一个虾纸丫 提交于 2019-12-17 02:28:58
问题 I want to use sha256 in my project, but I had some troubles rewriting objC code to swift code. Help me please. I used this answer: How can I compute a SHA-2 (ideally SHA 256 or SHA 512) hash in iOS? Here's my code var hash : [CUnsignedChar] CC_SHA256(data.bytes, data.length, hash) var res : NSData = NSData.dataWithBytes(hash, length: CC_SHA256_DIGEST_LENGTH) it gives me error everything because swift cannot convert Int to CC_LONG , for example. 回答1: You have to convert explicitly between Int

How to hash some string with sha256 in Java?

不羁岁月 提交于 2019-12-17 01:36:30
问题 How to hash some string with sha256 in Java ? Does anybody know any free library for this ? 回答1: SHA-256 isn't an "encoding" - it's a one-way hash. You'd basically convert the string into bytes (e.g. using text.getBytes(StandardCharsets.UTF_8) ) and then hash the bytes. Note that the result of the hash would also be arbitrary binary data, and if you want to represent that in a string, you should use base64 or hex... don't try to use the String(byte[], String) constructor. e.g. MessageDigest