sha

SHA256 base 64 hash generation in SQL Server

穿精又带淫゛_ 提交于 2019-12-01 00:06:30
I need to generate a SHA256 base 64 hash from a table in SQL server but I can't find that algorithm in the list HASHBYTES arguments. Is there a way to generate it directly in SQL Server? Duplicate disclamer: My question is not duplicate of SHA256 in T-sql stored procedure as I am looking for the SHA256 base 64 version of the algorithm which is not listed in the page. Numeric Example I have this query result in SQL Server Start date,End date,POD,Amount,Currency 2016-01-01,2016-12-31,1234567890,12000,EUR this give me the following string (using concatenate function) 2016-01-012016-12

Can you get this same Java SHA-1 in PHP please?

倖福魔咒の 提交于 2019-11-30 17:48:15
问题 I find myself in a need to change website platforms from Java to PHP but I'd like to keep all my user's passwords... I had this code do the password hashing prior to writting the hashed value as the password to the website: MessageDigest md = null; md = MessageDigest.getInstance("SHA"); md.update(plaintext.getBytes("UTF-8")); byte raw[] = md.digest(); hash = new Base64().encodeToString(raw).replaceAll("\n", "").replaceAll("\r", ""); I think the Java code did SHA-1 hashing of the password but

Why does Zipping the same content twice gives two files with different SHA1?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 17:24:43
I have run into a strange problem with git and zip files. My build script takes a bunch of documentation html pages and zips them into a docs.zip I then check this file into git. The problem I am having is that every time I re-run the build script and get a new zip file the new zip file has a different SHA1 than the previous run. My build script is calling the ant zip task. However manualy calling the macOSX zip from the Mac OS X shell gives me a different sha1 if I zip up the same directory twice. Run 1: zip foo.zip * openssl sha1 foo.zip rm foo.zip Run 2: zip foo.zip * openssl sha1 foo.zip

When generating a SHA256 / 512 hash, is there a minimum 'safe' amount of data to hash?

白昼怎懂夜的黑 提交于 2019-11-30 13:10:24
问题 I have heard that when creating a hash, it's possible that if small files or amounts of data are used, the resulting hash is more likely to suffer from a collision. If that is true, is there a minimum "safe" amount of data that should be used to ensure this doesn't happen? I guess the question could also be phrased as: What is the smallest amount of data that can be safely and securely hashed? 回答1: A hash function accepts inputs of arbitrary (or at least very high) length, and produces a

Creating signed URLs for Google Cloud Storage using NodeJS

吃可爱长大的小学妹 提交于 2019-11-30 12:50:06
I'm trying to create a signature for a privately stored file in Google Cloud Storage; so that I can distribute a time-limited link. Currently doing this and it makes a signature that's too short ... where am I going wrong? var crypto = require("crypto"); var ttl = new Date().getTime() + 3600; var id = 'the_target_file.txt'; var bucketName = 'bucket_name'; var POLICY_JSON = "GET\n" + "\n" + "\n" + ttl + "\n" + '/' + bucketName + '/' + id; // stringify and encode the policy var stringPolicy = JSON.stringify(POLICY_JSON); var base64Policy = Buffer(stringPolicy, "utf-8").toString("base64"); //

How does Git(Hub) handle possible collisions from short SHAs?

你离开我真会死。 提交于 2019-11-30 10:43:00
问题 Both Git and GitHub display short versions of SHAs -- just the first 7 characters instead of all 40 -- and both Git and GitHub support taking these short SHAs as arguments. E.g. git show 962a9e8 E.g. https://github.com/joyent/node/commit/962a9e8 Given that the possibility space is now orders of magnitude lower, "just" 268 million, how do Git and GitHub protect against collisions here? And how do they handle them? 回答1: These short forms are just to simplify visual recognition and to make your

git SHA1 0000000000000000000000000000000000000000 (all zeroes), is this normal?

ε祈祈猫儿з 提交于 2019-11-30 09:24:02
I have a yet uncommited branch in git with SHA1 0000000000000000000000000000000000000000 (all zeroes), is this normal or did I corrupt the git repository? Please don't answer yes there's one in 2^160, or 0.00000000000000000000000000000000000000000000006842277657836021% probabilities to have that SHA1. I am reasonably safe I'm not the lucky guy who got the SHA1 of 0000000000000000000000000000000000000000 in his git repository. A commit includes, among other metadata, the commit date. So the commit hash can't be displayed until the commit has actually been created. What you're seeing is not a

Does every Android phone support SHA-256

前提是你 提交于 2019-11-30 07:53:10
So reading this post: How can I calculate the SHA-256 hash of a string in Android? and the docs: http://developer.android.com/reference/java/security/MessageDigest.html I'm curious; which phones will support SHA-256? In the docs, the line about the 'NoSuchAlgorithmException' makes me think that some phones don't support all algorithms. Before I go implementing this for an app and expecting it to work the same on all phones I want to know if anyone knows anything about this...? I find it strange that the MessageDigest class doesn't have some constants to pick the algorithm you want to use. All

Convert Encrypt code in java to Ruby

佐手、 提交于 2019-11-30 07:41:37
I have been trying to convert a code for encrypt in java to ruby, but I am not able to do it completely. I getting different values. passphrase = passphrase + STATIC_KEY; byte[] key = passphrase.getBytes("UTF-8"); MessageDigest sha = MessageDigest.getInstance("SHA-1"); key = sha.digest(key); key = Arrays.copyOf(key, 16); SecretKey secretKey = new SecretKeySpec(key, "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); IvParameterSpec initialisationVector = new IvParameterSpec( new byte[16]); cipher.init(Cipher.ENCRYPT_MODE, secretKey, initialisationVector); byte[] encryptedData =

JWT (JSON Web Token) in PHP without using 3rd-party library. How to sign?

£可爱£侵袭症+ 提交于 2019-11-30 06:57:36
There are a few libraries for implementing JSON Web Tokens (JWT) in PHP, such as php-jwt . I am writing my own, very small and simple class but cannot figure out why my signature fails validation here even though I've tried to stick to the standard. I've been trying for hours and I'm stuck. Please help! My code is simple //build the headers $headers = ['alg'=>'HS256','typ'=>'JWT']; $headers_encoded = base64url_encode(json_encode($headers)); //build the payload $payload = ['sub'=>'1234567890','name'=>'John Doe', 'admin'=>true]; $payload_encoded = base64url_encode(json_encode($payload)); //build