sha256

Generate SHA256 hash in Objective-C

╄→гoц情女王★ 提交于 2019-12-03 11:51:25
So I need to generate a Sha256 password in Objective-C, and can't figure out for the life of me how to do it! Is there something easy I'm just missing? I've tried implementing the following method (which was written for iPhone, but I figured maybe it'd work cross-platform, as some Objective-C code does) -(NSString*)sha256HashFor:(NSString*)input { const char* str = [input UTF8String]; unsigned char result[CC_SHA256_DIGEST_LENGTH]; CC_SHA256(str, strlen(str), result); NSMutableString *ret = [NSMutableString stringWithCapacity:CC_SHA256_DIGEST_LENGTH*2]; for(int i = 0; i<CC_SHA256_DIGEST_LENGTH;

Compare two hashed password using same salt using SHA-256 algorith in Java, Spring security?

冷暖自知 提交于 2019-12-03 11:23:22
问题 I need some guidance on the scenario where I need to check the password coming from UI form (i.e, Authentication object) which I need to hashed using SHA-256 + constant salt (before making comparison) and password coming from DB (DB also has hashed password + salt) using Spring Security. I am looking to compare these two different hashed value generated using same SALT value. How we can do it in java? Could anyone please share me a sample code? 回答1: You could simply compare the two password

Download AWS S3 file from EC2 instance

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've a script to download file from AWS S3 and it works from a separate server outside of AWS. But when I put this script on an EC2 instance and tried it then it returns error "SignatureDoesNotMatch - The request signature we calculated does not match the signature you provided. Check your key and signing method." But it works on the other server. The ec2 is on the same region as the s3 host. I'm guessing it has something to do with the host. I tried these host/url but it returns the same error. Anyone able to download s3 files from ec2 with

Android (Java) method equivalent to Python HMAC-SHA256 in Hex

与世无争的帅哥 提交于 2019-12-03 10:15:58
I am attempting to replicate the Python HMAC-SHA256 equivalent in Android (Java). The Python representation is shown bellow with the correct output: Python print (hmac.new(key = binascii.unhexlify("0123465789"),msg = binascii.unhexlify("ABCDEF"),digestmod=hashlib.sha256).hexdigest()).upper() Output 5B5EE08A20DDD645A31384E51AC581A4551E9BE5AC8BF7E690A5527F2B9372CB However, I am unable to get the same output in Java using the code below: Java Mac sha256_HMAC = Mac.getInstance("HmacSHA256"); SecretKeySpec secretKey = new SecretKeySpec("0123465789".getBytes("UTF-8"), "HmacSHA256"); sha256_HMAC.init

Exception when calling MessageDigest.getInstance(“SHA256”)

放肆的年华 提交于 2019-12-03 09:36:14
问题 I have code that works well on Android. When I ported it to my Windows 64-bit machine with JRE 1.6, the code did not work. When I run the following line of code: final MessageDigest digest = MessageDigest.getInstance("SHA256") I get the following exception: java.security.NoSuchAlgorithmException: SHA256 MessageDigest not available at sun.security.jca.GetInstance.getInstance(Unknown Source) at java.security.Security.getImpl(Unknown Source) at java.security.MessageDigest.getInstance(Unknown

Matching Java SHA2 Output vs MySQL SHA2 Output

浪子不回头ぞ 提交于 2019-12-03 09:10:06
When I reproduce a SHA2 hash via the following code: MessageDigest digest = MessageDigest.getInstance("SHA-256"); digest.digest("A".getBytes("UTF-8")); it gives me a byte array, which is: 85,-102,-22,-48,-126,100,-43,121,93,57,9,113,-116,-35,5,-85,-44,-107,114,-24,79,-27,85,-112,-18,-13,26,-120,-96,-113,-33,-3 But when I reproduce same hash via MySQL it gives me a string which is: 5cfe2cddbb9940fb4d8505e25ea77e763a0077693dbb01b1a6aa94f2 How can I convert tha Java's result so that I can compare it with MySQL's result? First check out your DB result it looks like your initial hash is actually a

POI XSSF / XLSX hashing indeterminism with MessageDigest SHA-256

 ̄綄美尐妖づ 提交于 2019-12-03 08:48:39
There seems to be a problem with getting deterministic hash values for the POI XLSX format, with MessageDigest SHA-256 implementation, even for empty ByteArray streams. This happens randomly, after several hundreds or even only thousands of iterations. The relevant code snippets used to reproduce the problem: // TestNG FileTest: @Test(enabled = true) // indeterminism at random iterations, such as 400 or 1290 public void emptyXLSXTest() throws IOException, NoSuchAlgorithmException { final Hasher hasher = new HasherImpl(); boolean differentSHA256Hash = false; for (int i = 0; i < 10000; i++) {

signature with SHA256

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a smartcard and I need to sign a file with this. That is a big problem as I see in stackover. I couldnt use RSACryptoServiceProvider, bkz it doesnt support RSA-SHA256 alogrithm. At First I used CAPICOM.dll , like code bellow, SignedData sed = new SignedData(); sed.Content = "a"; // data to sign Signer ser = new Signer(); ser.Certificate = cc; string singnn = sed.Sign(ser, false, CAPICOM_ENCODING_TYPE.CAPICOM_ENCODE_BASE64); But there isnt a public key to validate my signature value,, I couldnt get a validate key from capicom.dll. And

TLS v1.2 ciphers to use in PHP NUSOAP SoapClient

匿名 (未验证) 提交于 2019-12-03 08:41:19
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to connect to a server that only supports TLS 1.2. What possible ciphers can I specify to stream context in the PHP NUSOAP SoapClient creation? <?php $objSoapClient = new SoapClient( "https://example.com/?wsdl", array( "encoding"=>"ISO-8859-1", "stream_context"=>stream_context_create( array( "ssl"=>array("ciphers"=>"<????>") ) ) ) ); ?> 回答1: TLS v1.2 is described in RFC5246 , you can read it here . List of ciphers you can find in openssl wiki , use the second line without trailing 256 . You can manually get a list of ciphers used by

SHA256 digest in perl

匿名 (未验证) 提交于 2019-12-03 08:41:19
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to do SHA256 hashing of email addresses and I need the result as a String. I tried the following: use Digest::SHA qw(sha256); my $data = 'swaranga@gmail.com'; my $digest = sha256($data); print $digest; But it prints something like: I need the output as follows: cbc41284e23c8c7ed98f589b6d6ebfd6 The above hash is generated using SHA256 generator of Apache DigestUtils . What am I doing wrong? I am a newbie in perl, so excuse if it is something silly. Thanks. 回答1: cbc41284e23c8c7ed98f589b6d6ebfd6 is MD5 for swaranga@gmail.com , not SHA