sha256

Generate sha256 with OpenSSL and C++

邮差的信 提交于 2019-11-26 21:38:43
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 Adam Lamers Here's how I did it: void sha256_hash_string (unsigned char hash[SHA256_DIGEST_LENGTH], char outputBuffer[65]) { int i = 0; for(i = 0; i < SHA256_DIGEST_LENGTH; i++) { sprintf

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

假如想象 提交于 2019-11-26 19:27:45
The Security services API doesn't appear to allow me to compute a hash directly. There are plenty of public domain and liberally licensed versions available, but I'd rather use a system library implementation if possible. The data is accessible via NSData, or plain pointers. The cryptographic strength of the hash is important to me. SHA-256 is the minimum acceptable hash size. alex-i This is what I'm using for SHA1: #import <CommonCrypto/CommonDigest.h> + (NSData *)sha1:(NSData *)data { unsigned char hash[CC_SHA1_DIGEST_LENGTH]; if ( CC_SHA1([data bytes], [data length], hash) ) { NSData *sha1

Are there any SHA-256 javascript implementations that are generally considered trustworthy?

↘锁芯ラ 提交于 2019-11-26 18:31:05
I am writing a login for a forum, and need to hash the password client side in javascript before sending it on to the server. I'm having trouble figuring out which SHA-256 implementation I can actually trust. I was expecting there to be some kind of authoritative script that everyone used, but I'm finding loads of different projects all with their own implementations. I realize using other people's crypto is always a leap of faith unless you're qualified to review it yourself, and that there is no universal definition of "trustworthy", but this seems like something common and important enough

How long is the SHA256 hash?

老子叫甜甜 提交于 2019-11-26 17:56:49
问题 I'm going to run SHA256 on a password + salt, but I don't know how long to make my VARCHAR when setting up the MySQL database. What is a good length? 回答1: A sha256 is 256 bits long -- as its name indicates. If you are using an hexadecimal representation, each digit codes for 4 bits ; so you need 64 digits to represent 256 bits -- so, you need a varchar(64) , or a char(64) , as the length is always the same, not varying at all. And the demo : $hash = hash('sha256', 'hello, world!'); var_dump(

Obtain SHA-256 string of a string

我的梦境 提交于 2019-11-26 16:32:28
I have some string and I want to hash it with the SHA-256 hash function using C#. I want something like this: string hashString = sha256_hash("samplestring"); Is there something built into the framework to do this? Dmitry Bychenko The implementation could be like that public static String sha256_hash(String value) { StringBuilder Sb = new StringBuilder(); using (SHA256 hash = SHA256Managed.Create()) { Encoding enc = Encoding.UTF8; Byte[] result = hash.ComputeHash(enc.GetBytes(value)); foreach (Byte b in result) Sb.Append(b.ToString("x2")); } return Sb.ToString(); } Edit: Linq implementation is

Hashing passwords with MD5 or sha-256 C#

纵饮孤独 提交于 2019-11-26 15:38:46
I'm writing a register form for a application but still having problems with being new to c#. I am looking to encrypt/hash passwords to md5 or sha-256, preferably sha-256. Any good examples? I want it to be able to take the information from "string password;" and then hash it and store in the variable "string hPassword;". Any ideas? Don't use a simple hash, or even a salted hash. Use some sort of key-strengthening technique like bcrypt (with a .NET implementation here ) or PBKDF2 (with a built-in implementation ). Here's an example using PBKDF2. To generate a key from your password... string

SHA256 in swift

痞子三分冷 提交于 2019-11-26 15:19:14
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. You have to convert explicitly between Int and CC_LONG , because Swift does not do implicit conversions, as in (Objective-)C. You also have to define

SHA1 vs md5 vs SHA256: which to use for a PHP login?

a 夏天 提交于 2019-11-26 14:03:25
I'm making a php login, and I'm trying to decide whether to use SHA1 or Md5, or SHA256 which I read about in another stackoverflow article. Are any of them more secure than others? For SHA1/256, do I still use a salt? Also, is this a secure way to store the password as a hash in mysql? function createSalt() { $string = md5(uniqid(rand(), true)); return substr($string, 0, 3); } $salt = createSalt(); $hash = sha1($salt . $hash); Johannes Gorset Neither. You should use bcrypt . The hashes you mention are all optimized to be quick and easy on hardware, and so cracking them share the same qualities

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

徘徊边缘 提交于 2019-11-26 12:20:02
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 forgot to mention it, thanks mata). Sign hash: openssl rsautl -sign -inkey private.pem -keyform PEM

Calculating a SHA hash with a string + secret key in python

☆樱花仙子☆ 提交于 2019-11-26 11:57:35
问题 Amazon Product API now requires a signature with every request which I\'m trying to generate ushing Python. The step I get hung up on is this one: \"Calculate an RFC 2104-compliant HMAC with the SHA256 hash algorithm using the string above with our \"dummy\" Secret Access Key: 1234567890. For more information about this step, see documentation and code samples for your programming language.\" Given a string and a secret key (in this case 1234567890) how do I calculate this hash using Python?