Return sha1() hash from couchdb

I have some data stored in CouchDb of the form key-value. Basically it a tuple with a value and salt. I have created a view that return these tuples and calculate the sha1() of the value + salt on the client side using javascript. Is it possible to send the sha1() hash of value + salt directly from CouchDb as JSON? I do not wish to send the salt to the client. Thanks.

-------------Problems Reply------------

I suggest a Javascript SHA1 [1] implementation directly on CouchDB. I think you have two options:

  1. Compute the checksum in the view. Query speed will be unchanged, but the view code will grow a bit.
  2. Compute the checksum in a _list function. Query speed will be (in principle) slower, since you execute code for every row for every query; but your views can remain simple.

There is an SHA1 Javascript implementation in CouchDB! Point your browser to your Couch server, in /_utils/script/sha1.js. You can copy and paste the code if you want.

[1] Or consider SHA256 or SHA512 if possible.

Category:javascript Views:0 Time:2011-07-06

Related post

  • Will a SHA1 Hash in C# always and forever return the same value for a given string? 2011-07-23

    I am considering changing the method whereby we encrypt passwords to use a one-way hash rather than an encryption. I considered using a simple "GetHashCode" on the password string but MS warns that this function may change in the future and is differ

  • How do I create a SHA1 hash in ruby? 2008-08-29

    SHA Hash functions --------------Solutions------------- require 'digest/sha1' Digest::SHA1.hexdigest 'foo' For a Base64 encoded hash, to validated an Oauth signature, I used require 'base64' require 'hmac-sha1' Base64.encode64((HMAC::SHA1.new('key')

  • Storing SHA1 hash values in MySQL 2009-03-05

    I have a simple question which occured when I wanted to store the result of a SHA1 hash in a MySQL database: How long should the VARCHAR field be in which I store the hash's result? --------------Solutions------------- I would use VARCHAR for variabl

  • How do I sha1 hash hex values correctly in PHP? 2009-03-05

    I have a series of hex bytes. Theoretically, the last 20 bytes are the sha1 hash of the first part: 3F F4 E5 25 98 20 52 70 01 63 00 68 00 75 00 79 00 69 00 00 00 74 28 96 10 09 9D C9 01 00 74 A0 D7 DB 0B 9D C9 01 4D 00 79 00 47 00 72 00 6F 00 75 00

  • If .net sha1 hash expects a byte array, and php sha1() wants a string, can I match the results? 2009-03-05

    I have a set of bytes I want to apply an sha1 hash to. One hash will be in .net, the other in PHP. Then I'll test to see if they match. In .net, you can create a byte array and use sha.ComputeHash(). byte[] data = new byte[DATA_SIZE]; byte[] result;

  • How is the machineKey validationKey used when creating a sha1 hash? 2009-03-06

    <machineKey validation="SHA1" validationKey="<64-byte key>" What exactly does the validationKey do? Say I create a hash with SHA1. How does the validationKey play in to it? Consider this code: HMACSHA1 hashSha = new HMACSHA1(_validationKey);

  • SHA1 hashes not matching between my Rails and Cocoa apps 2009-03-27

    I have a Cocoa app send some data along with a SHA1 hash of that data to a Rails app which verifies that the data and the hash match, but they do not. To be sure I have logged hex versions of the data that is hashed to the console at both the Rails a

  • SHA1 hash different in Vista and XP 2009-10-19

    In a WinForm application using C#.NET 2.0 (on Vista), I am using SHA1 hash to create a hash from a string and store the hash in a text file (with UTF-8 encoding). I want to use the hash stored in text file to in a condition. When I run the project in

  • SHA1 hashing in SQLite: how? 2010-07-05

    Working with several DBs in parallel and need to initialize some records with hashed passwords. In MS SQL server there are handy functions that allow to hash on the fly: HashBytes('SHA1', CONVERT(nvarchar(32), N'admin')) Is there is a similar functio

  • Different SHA1 Hash result between Java and C# 2010-07-08

    I've a big problem. I using this C# function to encode my message: byte[] buffer = Encoding.ASCII.GetBytes(file_or_text); SHA1CryptoServiceProvider cryptoTransformSHA1 = new SHA1CryptoServiceProvider(); String hashText = BitConverter.ToString(cryptoT

  • Issues with SHA1 hash implementation in Android 2011-06-14

    I have two small snippets for calculating SHA1. One is very fast but it seems that it isn't correct and the other is very slow but correct. I think the FileInputStream conversion to ByteArrayInputStream is the problem. Fast version: MessageDigest md

  • Is there a simple C or C++ function that calculates the sha1 hash of a string? 2011-08-03

    Possible Duplicate: sha1 function in cpp (C++)Hi, I was just looking for a function that calculates the sha1 hash of string and returns the result. --------------Solutions------------- Not built-in. Try openssl's crypto library. (http://www.openssl.o

  • Convert php array and sha1 hashing function to c# 2011-08-08

    As service provider has given me the following php code, which I need to replicate in C# $aData = array('merchant_id' => 'your merchant ID', // 123456 'project_id' => 'your project ID', // 242342 'amount' => 'amount', // 199 = 1,99 EUR 'curr

  • How can I get the sha1 hash of a string in node.js? 2011-08-08

    I'm trying to create a websocket server written in node.js To get the server to work I need to get the SHA1 hash of a string. What I have to do is explained in Section 5.2.2 page 35 of the docs. NOTE: As an example, if the value of the "Sec-WebSocket

  • Same string, different SHA1 hash values obtained from VB.net and PHP 2011-09-07

    I have some problems with the SHA1 hash value of a string. I'm trying to send a file from a client written in VB.net to a server written in PHP. My problem is that when I pass the same string to VB.net and PHP, the SHA1 value calculated by VB.net is

  • How to generate random SHA1 hash to use as ID in node.js? 2012-02-23

    I am using this line to generate a sha1 id for node.js: crypto.createHash('sha1').digest('hex'); The problem is that it's returning the same id every time. Is it possible to have it generate a random id each time so I can use it as a database documen

  • Best way to compare sha1 hashes for equality 2012-03-14

    I want to compare two sha1 hashes for equality. What could be the most efficient way to do this? Currently, I am trying using memcmp. Thanks. --------------Solutions------------- Well, since you already know at compile-time how large the blocks are,

  • Generate SHA1 Hash in Portable Class Library 2012-04-20

    I'm trying to build a portable class library that generates OAuth urls for other classes/applications to use. This class library using OAuth has to be a portable class library so it can work with different versions of a DropBox API I'm building. Part

  • Find a "native" dll which calculates a MD5/SHA1 hash in windows 2003 server 2009-01-26

    Does anyone know if there exist a dll in windows (2003 server) which I can call to calculate a MD5/SHA1 hash for a string? I've written a .dll in C# that do this but I'm not allowed to use this because of company regulations for our servers. /Ausgar

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.202 (s). 11 q(s)