mirror of
https://github.com/moparisthebest/mail
synced 2024-08-13 16:43:47 -04:00
25 lines
607 B
JavaScript
25 lines
607 B
JavaScript
'use strict';
|
|
|
|
importScripts('forge.min.js');
|
|
|
|
var pbkdf2 = require('./pbkdf2');
|
|
|
|
/**
|
|
* In the web worker thread context, 'this' and 'self' can be used as a global
|
|
* variable namespace similar to the 'window' object in the main thread
|
|
*/
|
|
self.onmessage = function(e) {
|
|
var i = e.data,
|
|
key = null;
|
|
|
|
if (i.password && i.salt && i.keySize) {
|
|
// start deriving key
|
|
key = pbkdf2.getKey(i.password, i.salt, i.keySize);
|
|
|
|
} else {
|
|
throw 'Not all arguments for web worker crypto are defined!';
|
|
}
|
|
|
|
// pass output back to main thread
|
|
self.postMessage(key);
|
|
}; |