sha512

How to convert a raw 64-byte binary to Hex or ASCII in C

北战南征 提交于 2021-02-10 16:17:49
问题 I´m using SHA512 in C to get an Hash-Value. I did it like this: #include <stdlib.h> #include <stdio.h> #include <openssl/sha.h> int main(int argc, char *argv[]){ unsigned char hash[SHA512_DIGEST_LENGTH]; char data[] = "data to hash"; //Test Data SHA512(data, sizeof(data) - 1, hash); //Kill termination character //Now there is the 64byte binary in hash I tried to convert it to hex by: long int binaryval, hexadecimalval = 0, i = 1, remainder; binaryval=(long int)hash; while (binaryval != 0) {

Objective C SHA512 hash of two NSData

自作多情 提交于 2020-01-22 17:07:07
问题 Here is a Java code, which computes SHA512 hash of a byte array with salt: private static String DIGEST_ALGORITHM = "SHA-512"; public static byte[] getHash(final byte[] data, final byte[] salt) throws NoSuchAlgorithmException { final MessageDigest md = MessageDigest.getInstance(DIGEST_ALGORITHM); md.reset(); if (salt != null) { md.update(salt); } return md.digest(data); In Objective C, I use this algorithm for compute the hash of an NSData: @implementation NSData (CommonDigest) - (NSData *)

Migrating passwords from web2py to Django

ε祈祈猫儿з 提交于 2020-01-17 04:11:29
问题 I have passwords stored in web2py using SHA 512 algorithm. I am now migrating the models to django and hence need a way to hash passwords in django using SHA 512 in the same way as web2py does so that I can authenticate the old users with the same passwords.Please suggest some way. 回答1: According to this post a Python snippet to recreate the convention used in web2py would be the following: from hashlib import md5 import hmac hmac_key = '<your secret key>' password = 'insecure' thehash = hmac

Using 512-hash before Bcrypt?

吃可爱长大的小学妹 提交于 2020-01-15 14:24:07
问题 I want to use Bcrypt for the password encryption in my systems. But all the examples are something like this: $password = $_POST['password']; $salt = substr(str_replace('+', '.', base64_encode(sha1(microtime(true), true))), 0, 22); $hash = crypt($password, '$2a$12$'.$salt); This looks pretty safe to me, but I was wondering, in each example, nobody hashes the password before using Bcrypt. Due to the unique salt, Rainbow tables shouldn't be able to crack all the passwords at once. But in case

cryto.createHash sha512 with hexDigest input type

孤街浪徒 提交于 2020-01-14 14:29:06
问题 I am trying to get the same result I obtain at http://jssha.sourceforge.net/ where I have the word 'testing' in question: var word = 'testing'; var hex = toHex(word); // '740065007300740069006e006700'; on jssha when selecting input type as HEX with the value of the hex variable and SHA-512 I get the following result: 6e42b2c2a6351036b78384212774135d99d849da3066264983e495b5f74dc922e3d361b8ea9c8527169757233ed0bd4e56b2c42aab0a21bbcca67219dc53b472 although I can't achieve the same result with

How to calculate a SHA-512 hash in C++ on Linux?

ⅰ亾dé卋堺 提交于 2020-01-12 04:45:09
问题 Is there a standard library or commonly used library that can be used for calculating SHA-512 hashes on Linux? I'm looking for a C or C++ library. 回答1: Have you checked OpenSSL. I myself have not used it but documentation says it supports it. Here is list of few more implementations. Example code md = EVP_get_digestbyname("sha512"); EVP_MD_CTX_init(&mdctx); EVP_DigestInit_ex(&mdctx, md, NULL); EVP_DigestUpdate(&mdctx, mess1, strlen(mess1)); EVP_DigestUpdate(&mdctx, mess2, strlen(mess2)); EVP