sha

How so I convert this SHA256 + BASE64 from Swift to PHP?

心已入冬 提交于 2019-12-02 18:13:39
问题 I've been given this Swift code to try and make work in PHP: finalStr = Encryption.sha256(inputStr) ... class Encryption { static func sha256(_ data: Data) -> Data? { guard let res = NSMutableData(length: Int(CC_SHA256_DIGEST_LENGTH)) else { return nil } CC_SHA256((data as NSData).bytes, CC_LONG(data.count), res.mutableBytes.assumingMemoryBound(to: UInt8.self)) return res as Data } static func sha256(_ str: String) -> String? { guard let data = str.data(using: String.Encoding.utf8), let

Hashing in SHA512 using a salt? - Python

╄→гoц情女王★ 提交于 2019-12-02 17:54:10
I have been looking through ths hashlib documentation but haven't found anything talking about using salt when hashing data. Help would be great. Rakis Samir's answer is correct but somewhat cryptic. Basically, the salt is just a randomly derived bit of data that you prefix or postfix your data with to dramatically increase the complexity of a dictionary attack on your hashed value. So given a salt s and data d you'd just do the following to generate a salted hash of the data: import hashlib hashlib.sha512( s + d ).hexdigest() See this wikipedia article for more details Just add the salt to

How to reverse SHA1 Encrypted text [duplicate]

让人想犯罪 __ 提交于 2019-12-02 13:37:02
This question already has an answer here: Is it possible to reverse a sha1? 9 answers I have a requirement to reverse translate a SHA1 encrypted text to plain text. I need the Java Code to it. many forums say that it cant be done but i have found a link http://www.stringfunction.com/sha1-decrypter.html which does exactly the same. I have tested it. Now i need the algorithm to implement in Java. Please help!!! It's plain impossible. SHA1, like all cryptographic digest algorithms, is not an encryption algorithm, but a hashing algorithm. It takes any text, as long as you want, and transforms it

How so I convert this SHA256 + BASE64 from Swift to PHP?

懵懂的女人 提交于 2019-12-02 11:11:33
I've been given this Swift code to try and make work in PHP: finalStr = Encryption.sha256(inputStr) ... class Encryption { static func sha256(_ data: Data) -> Data? { guard let res = NSMutableData(length: Int(CC_SHA256_DIGEST_LENGTH)) else { return nil } CC_SHA256((data as NSData).bytes, CC_LONG(data.count), res.mutableBytes.assumingMemoryBound(to: UInt8.self)) return res as Data } static func sha256(_ str: String) -> String? { guard let data = str.data(using: String.Encoding.utf8), let shaData = Encryption.sha256(data) else { return nil } let rc = shaData.base64EncodedString(options: [])

Encrypt passwords on Sql Server 2008 using SHA1

给你一囗甜甜゛ 提交于 2019-12-02 07:01:37
问题 I have designed a Log In System using C# where the username and password is checked in SQL server 2008 before loading the main page. I wish to encrypt the stored password on the database. Is it possible to do it using C# and SHA1 algorithm? Following is my stored procedure: ALTER procedure [dbo].[proc_UserLogin] @userid varchar(20), @password nvarchar(50) As declare @ReturnVal varchar(500) SET NOCOUNT ON if exists(select userid,password from LoginManager where userid=@userid and password=

How to generate RSA SHA signature using OpenSSL in C

时光怂恿深爱的人放手 提交于 2019-12-01 21:21:37
问题 I need some help using OpenSSL to generate a signature of a block of data using C (Windows and Linux). The application has to do with Google authentication. The instructions from Google's documentation are: "Sign the UTF-8 representation of the input using SHA256withRSA (also known as RSASSA-PKCS1-V1_5-SIGN with the SHA-256 hash function) with the private key obtained from the Google Developers Console. The output will be a byte array." The private key is a .p12 file containing 1660 bytes of

Generating a pseudo-natural phrase from a big integer in a reversible way

戏子无情 提交于 2019-12-01 17:56:59
I have a large and "unique" integer (actually a SHA1 hash). Note: While I'm talking here about SHA1 hashes, this is not a cryptography / security question! I'm not trying to break SHA1. Imagine a random 160-bit integer instead of SHA1 if that will help. I want (for no other reason than to have fun) to find an algorithm to map that SHA1 hash to a computer-generated (pseudo-)English phrase. The mapping should be bidirectional (i.e., knowing the algorithm, one must be able to calculate the original SHA1 hash from that phrase.) The phrase need not make sense. I would even settle for a whole

Generating a pseudo-natural phrase from a big integer in a reversible way

*爱你&永不变心* 提交于 2019-12-01 17:39:23
问题 I have a large and "unique" integer (actually a SHA1 hash). Note: While I'm talking here about SHA1 hashes, this is not a cryptography / security question! I'm not trying to break SHA1. Imagine a random 160-bit integer instead of SHA1 if that will help. I want (for no other reason than to have fun) to find an algorithm to map that SHA1 hash to a computer-generated (pseudo-)English phrase. The mapping should be bidirectional (i.e., knowing the algorithm, one must be able to calculate the

perl shasum vs bash shasum

非 Y 不嫁゛ 提交于 2019-12-01 17:12:40
The following bash and Perl scripts mysteriously give different results. Why? #!/bin/bash hash=`echo -n 'abcd' | /usr/bin/shasum -a 256`; echo $hash; #!/usr/bin/perl $hash = `echo -n 'abcd' | /usr/bin/shasum -a 256`; print "$hash"; The bash script: $ ./tst.sh 88d4266fd4e6338d13b845fcf289579d209c897823b9217da3e161936f031589 - The Perl script: $ ./tst.pl 61799467ee1ab1f607764ab36c061f09cfac2f9c554e13f4c7442e66cbab9403 - the heck? Summary: In your Perl script, -n is being treated as an argument to include in the output of echo , not a flag to suppress the newline. ( Try $hash = `echo -n 'abcd'`;

perl shasum vs bash shasum

北城余情 提交于 2019-12-01 16:28:23
问题 The following bash and Perl scripts mysteriously give different results. Why? #!/bin/bash hash=`echo -n 'abcd' | /usr/bin/shasum -a 256`; echo $hash; #!/usr/bin/perl $hash = `echo -n 'abcd' | /usr/bin/shasum -a 256`; print "$hash"; The bash script: $ ./tst.sh 88d4266fd4e6338d13b845fcf289579d209c897823b9217da3e161936f031589 - The Perl script: $ ./tst.pl 61799467ee1ab1f607764ab36c061f09cfac2f9c554e13f4c7442e66cbab9403 - the heck? 回答1: Summary: In your Perl script, -n is being treated as an