sha

cherry-pick a commit and keep original SHA code

大兔子大兔子 提交于 2020-07-31 07:51:44
问题 I would like to cherry-pick a commit on a fetched remote while keeping it's original SHA commit code (my current branch is based on this remote which I resetted to a previous state). 回答1: A git SHA hash is computed from different pieces of information: The tree it refers to; basically, the current content of the repository in the branch in which the commit appears. The SHA of the parent commit(s) . The commit message . The author information : name, email and timestamp. The committer

Dump a ```sha``` checksum output to disk in binary format instead of plaintext hex in bash

孤者浪人 提交于 2020-03-26 15:10:36
问题 I want to dump a sha checksum (here using sha1sum , I know it is not to be used for crypto, do not worry this is fine for my need) to disk from a bash script. So far, I am able to get it dumped (without anything extra...). But I do not manage to dump it in binary format, instead I am only getting a plaintext hex dump: $ echo "bla" | sha1sum | awk '{print $1}' | head -c-1 > test $ ls -lrth test -rw-r--r-- 1 jrlab jrlab 40 mars 2 15:02 test $ xxd test 00000000: 3034 3735 3935 6430 6661 6539

What pool of characters do MD5 and SHA have?

时光怂恿深爱的人放手 提交于 2020-03-17 10:02:20
问题 Does MD5 and SHA only contain alphanumeric characters? (i.e., from A to Z and 0 to 9, or do they exclude some characters?) 回答1: MD5 and SHA hashes in raw form are binary, however their common representation is a hex-encoded string, which contains characters [a-fA-F0-9] . So if this is what you meant, then characters G-Z, g-z are "excluded". Another, less common, representation is Base64 encoding [0-9a-zA-Z+/]. 来源: https://stackoverflow.com/questions/12618321/what-pool-of-characters-do-md5-and

Getting MD5 and SHA-1

£可爱£侵袭症+ 提交于 2020-01-22 07:33:10
问题 I am looking for some help in getting MD5 and SHA-1 in my iPhone app. Can anybody give me an idea on how to get these? 回答1: #include <CommonCrypto/CommonDigest.h> -(NSString*) sha1:(NSString*)input { NSData *data = [input dataUsingEncoding: NSUTF8StringEncoding]; uint8_t digest[CC_SHA1_DIGEST_LENGTH]; CC_SHA1(data.bytes, data.length, digest); NSMutableString* output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2]; for(int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++) [output

OpenSSL SHA1 not validating NIST SHAKE test vector?

坚强是说给别人听的谎言 提交于 2020-01-17 07:14:44
问题 I have written a C code which calls on OpenSSL SHA1 to generate a digest but my generated digest is not matching. #define MSG_SIZE 190 #include <stdio.h> #include <string.h> #include <openssl/sha.h> void str2hex(char *str, unsigned char *hex, int len) { int tt, ss; char temp[5]; for (tt = 0, ss = 0; tt < len, ss < 2 * len; tt++, ss += 2) { temp[0] = '0'; temp[1] = 'x'; temp[2] = str[ss]; temp[3] = str[ss + 1]; temp[4] = 0; hex[tt] = strtol(temp, NULL, 0); } } int main() { unsigned char digest

SHA256 in Go and PHP giving different results

自闭症网瘾萝莉.ら 提交于 2020-01-14 09:58:34
问题 I'm trying to send a SHA256 hashed string over HTTP to a server, where I want to authenticate by performing a SHA256 hash and verifying the two match. For testing purposes I'm using the same string, however my results do not match up. Could this be something with default encoding schemes for my base64_encode calls? Thanks. In PHP I'm doing: $sha = hash("sha256", $url, true); $sha = base64_encode(urlencode($sha)); And in Go I'm doing //convert string to byte slice converted := []byte(to_hash)

Using ruby to generate SHA512 crypt-style hashes formatted for /etc/shadow?

大憨熊 提交于 2020-01-12 07:41:19
问题 I want to generate SHA512 hashed passwords for inclusion directly into a /etc/shadow file for use with chef's user resource. Normally I'd go to the stdlib's Digest library for this, but it doesn't generate the hash in the right format: ruby-1.9.2-p136 :001 > require 'digest/sha2' => true ruby-1.9.2-p136 :002 > Digest::SHA512.hexdigest('test') => "ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff" The format that

Comparing SHA Checksum values in C

人走茶凉 提交于 2020-01-06 15:02:11
问题 I am working on an assignment for creating a shell in C. The program have to read a config file, where the commands that are allowed in the shell are listed. Also in this config file, for every command that is allowed, it's sha1 checksum value is also listed. A sample line would look like this: (the file has other data too) ... other data .... * /bin/ls 3848bdeada63dc59d2117a6ca1348fe0981ad2fc When the user types a command, the program has to check if that command is in config file or not. If

Comparing SHA Checksum values in C

前提是你 提交于 2020-01-06 15:01:37
问题 I am working on an assignment for creating a shell in C. The program have to read a config file, where the commands that are allowed in the shell are listed. Also in this config file, for every command that is allowed, it's sha1 checksum value is also listed. A sample line would look like this: (the file has other data too) ... other data .... * /bin/ls 3848bdeada63dc59d2117a6ca1348fe0981ad2fc When the user types a command, the program has to check if that command is in config file or not. If

HMAC produces wrong results

依然范特西╮ 提交于 2020-01-04 05:28:05
问题 All of this is new to me so please forgive my noobish question. I'm trying to figure out HMAC step by step. Let's say I have a following SHA-1 method: public static string SHA_1(string input) { SHA1CryptoServiceProvider mySha = new SHA1CryptoServiceProvider(); string temp = BitConverter.ToString(mySha.ComputeHash(Encoding.UTF8.GetBytes(input))); temp = temp.Replace("-", "").ToUpper(); return temp; } It receives a plain text string; Let's say my secret key is "" (empty string) and so is the