digest

Lightweight 8 byte hash function algorithm

那年仲夏 提交于 2019-11-30 03:55:12
问题 I need to extract an 8 byte digest from a variable length string so I'm looking for such an algorithm that I will implement in c/c++. That will be part of a digital signature procedure on a microcontroller, so it has to be: writable in few lines of code, since the firmware has to be kept as little as possible; low in resource consumption, expecially ram (preferably less than 100 bytes); strong enough that changing a single character at any point of the string would change the overall digest.

XML Signature: How to calculate the digest value?

拥有回忆 提交于 2019-11-29 23:04:55
I have an XML like this <?xml version="1.0" encoding="utf-8"?> <foo> <bar> <value>A</value> </bar> <bar> <value>B</value> </bar> <baz> <value>C</value> </baz><Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /><Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /></Transforms><DigestMethod Algorithm="http

Glassfish Security - jdbcRealm: How to configure login with SHA-256 digest

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 22:40:06
I use jdbcRealm for security in my glassfish v3.0.1 b22. It is set up so that it use the USER table inside my database for authentication by following this blog: http://blogs.oracle.com/foo/entry/mort_learns_jdbc_realm_authentication . I got it working fine, if I leave the digest algorithm as plain text. However when i try to use SHA-256 for digest algorithm, it stop working. What I did is specify in Glassfish - Security - Realm - jdbcRealm - digest that I want SHA-256 (I just type SHA-256 inside digest field). Then I wrote a simple Java program to convert password text into SHA-256 hash. I

Can I prevent / delay the AngularJS $digest from happening when model is updated

≡放荡痞女 提交于 2019-11-29 13:23:49
Is there a way to postpone or delay a digest from happening? I have a bunch of changes that I want to make to a model but I don't want the digest to fire until all changes to the model were made. Some of the objects on the model have watchers that update other objects on the model to change. Ideally I'd like to Stop the $digest Make all changes to the model Start the $digest The $digest will find all dirty objects and fire the watchers. Another solution to this is to, instead of stopping $digest I could Remove the watchers Make all changes to the model (digest still runs) Add the watchers that

What does [“string”].pack('H*') mean?

假如想象 提交于 2019-11-29 04:21:16
I need to translate some Ruby code to JavaScript and came across the following function: def sha1_hex(h) Digest::SHA1.hexdigest([h].pack('H*')) end What exactly does [h].pack('H*') mean in this context? How would it translate to JavaScript? undur_gongor It interprets the string as hex numbers, two characters per byte, and converts it to a string with the characters with the corresponding ASCII code: ["464F4F"].pack('H*') # => "FOO", 0x46 is the code for 'F', 0x4F the code for 'O' For the opposite conversion, use unpack : 'FOO'.unpack('H*') # => ["464f4f"] It is a little bit more difficult for

XML Signature: How to calculate the digest value?

烈酒焚心 提交于 2019-11-28 20:09:18
问题 I have an XML like this <?xml version="1.0" encoding="utf-8"?> <foo> <bar> <value>A</value> </bar> <bar> <value>B</value> </bar> <baz> <value>C</value> </baz><Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />

Get MD5 String from Message Digest

折月煮酒 提交于 2019-11-28 18:55:56
问题 I understand how it works but if I want to print out the MD5 as String how would I do that? public static void getMD5(String fileName) throws Exception{ InputStream input = new FileInputStream(fileName); byte[] buffer = new byte[1024]; MessageDigest hash = MessageDigest.getInstance("MD5"); int read; do { read = input.read(buffer); if (read > 0) { hash.update(buffer, 0, read); } } while (read != -1); input.close(); } 回答1: Try this StringBuffer hexString = new StringBuffer(); MessageDigest md =

How can I calculate the SHA-256 hash of a string in Android?

心不动则不痛 提交于 2019-11-28 16:49:18
I'm trying to get the SHA256 of a string in Android. Here is the PHP code that I want to match: echo bin2hex(mhash(MHASH_SHA256,"asdf")); //outputs "f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b" Now, in Java, I'm trying to do the following: String password="asdf" MessageDigest digest=null; try { digest = MessageDigest.getInstance("SHA-256"); } catch (NoSuchAlgorithmException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } digest.reset(); try { Log.i("Eamorr",digest.digest(password.getBytes("UTF-8")).toString()); } catch (UnsupportedEncodingException e) { //

Sign PDF using an external service and iText

不问归期 提交于 2019-11-28 14:03:57
I have this scenario. I have an application that generates a PDF, and that needs to be signed. We have not the certificates to sign the document, because they're in a HSM, and the only way we could make use of the certificates is using a webservice. This webservice, offers two options, send the PDF document, and it returns a signed pdf, or send a hash that will be signed. The first option, is not viable, because the PDF is signed without a timestamp (this is a very important requisite), so the second option is chosen. This is our code, first, we get the signature appearance, and calculate the

Insert hidden digest in pdf using iText library

帅比萌擦擦* 提交于 2019-11-28 10:38:54
I search a method for insert a digest (byte array or String) into PDF file using iText library (Java). I create the digest from a String with this method: private String crypt(double x, ByteArrayOutputStream baos) throws UnsupportedEncodingException, NoSuchAlgorithmException{ MessageDigest md = MessageDigest.getInstance("SHA-256"); md.update(String.valueOf(x).getBytes("UTF-8")); md.update(String.valueOf(baos).getBytes("UTF-8")); byte[] digest = md.digest(); StringBuffer sb = new StringBuffer(); for(byte d:digest){ sb.append(Integer.toHexString(0xFF & d)); } return sb.toString(); } The digest