Created
          September 13, 2016 10:09 
        
      - 
      
 - 
        
Save MatthieuLemoine/2d00582ed7d46b806ff9e370066b274b to your computer and use it in GitHub Desktop.  
    Verify hash on CouchDB
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | const crypto = require('crypto'); | |
| const basicAuthToken = 'Yaaadfg9obGk6YTmleDI0ZGJiZg=='; | |
| const authToken = new Buffer(basicAuthToken, 'base64').toString('ascii'); | |
| const [username, password] = authToken.split(':'); | |
| const derivedKey = 'YaaadYaaadf569da661ac474db5d229547595a33'; | |
| const salt = 'YaaadfYaaadfd91037e9aa67e946f692'; | |
| const iterations = 10; | |
| crypto.pbkdf2(password, salt, iterations, derivedKey.length / 2, (err, verify) => { | |
| if (err) { | |
| console.error(err); | |
| } else { | |
| console.log(verify.toString('hex')); | |
| console.log(verify.toString('hex') === derivedKey); | |
| } | |
| }); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment