-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved documentation #3
Comments
The utility functions in particular, could use some help. These might already exist elsewhere in the module but I found adding these useful... sodium.api.crypto_box_random_nonce = function (){
var nonce = new Buffer(sodium.crypto_box_NONCEBYTES);
sodium.randombytes_buf(nonce);
return nonce
}
sodium.api.to_hex = function (args) {
var ret = "";
for ( var i = 0; i < args.length; i++ )
ret += (args[i] < 16 ? "0" : "") + args[i].toString(16);
return ret; //.toUpperCase();
}
sodium.api.from_hex = function (str) {
if (typeof str == 'string') {
var ret = new Uint8Array(Math.floor(str.length / 2));
var i = 0;
str.replace(/(..)/g, function(str) { ret[i++] = parseInt(str, 16);});
return ret;
}
} |
I will add the to_hex and from_hex. Random nonce is already generated by the nonce classes. |
Added to the Utils as 'api' is reserved to the core lib sodium functions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Have just started using node-sodium. Fantastic library but an absolute pain to get up and running with due to the combination of 'very-light' documentation and the dynamic nature of javascript.
Would http://www.verious.com/code/adamcaudill/libsodium-net/ be of any value in getting improved documentation up and running or perhaps this (generated by https://gist.github.com/m1sta/8229574)...
The text was updated successfully, but these errors were encountered: