Commit 71ff8049 authored by David Burke's avatar David Burke

Added randombytes_uniform function

parent 47f9113b
......@@ -26,6 +26,7 @@ export declare class Common {
static crypto_secretbox_open_easy(ciphertext: Uint8Array, nonce: Uint8Array, key: Uint8Array): Uint8Array;
static crypto_box_seal(message: string | Uint8Array, publicKey: Uint8Array): Uint8Array;
static crypto_box_seal_open(ciphertext: Uint8Array, publicKey: Uint8Array, secretKey: Uint8Array): Uint8Array;
static randombytes_uniform(upper_bound: number): number;
static readonly crypto_aead_chacha20poly1305_ABYTES: number;
static readonly crypto_aead_chacha20poly1305_KEYBYTES: number;
static readonly crypto_aead_chacha20poly1305_NPUBBYTES: number;
......
......@@ -181,6 +181,10 @@ export class Common {
return this.javaByteArrayToUint8Array(decrypted);
}
public static randombytes_uniform(upper_bound: number) {
return Sodium.randombytes_uniform(upper_bound);
}
public static get crypto_aead_chacha20poly1305_ABYTES() { return Sodium.crypto_aead_chacha20poly1305_abytes(); }
public static get crypto_aead_chacha20poly1305_KEYBYTES() { return Sodium.crypto_aead_chacha20poly1305_keybytes(); }
public static get crypto_aead_chacha20poly1305_NPUBBYTES() { return Sodium.crypto_aead_chacha20poly1305_npubbytes(); }
......@@ -270,6 +274,9 @@ export class Common {
msg += `decrypted is ${decryptedString}\n`;
let randomNumber = this.randombytes_uniform(10);
msg += `A random number between 0 and 10 is ${randomNumber}\n`;
return msg;
}
}
{
"name": "nativescript-libsodium",
"version": "1.3.0",
"version": "1.3.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......@@ -22,7 +22,7 @@
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"dev": true,
"requires": {
"sprintf-js": "1.0.3"
"sprintf-js": "~1.0.2"
}
},
"async": {
......@@ -37,9 +37,9 @@
"integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=",
"dev": true,
"requires": {
"chalk": "1.1.3",
"esutils": "2.0.2",
"js-tokens": "3.0.2"
"chalk": "^1.1.3",
"esutils": "^2.0.2",
"js-tokens": "^3.0.2"
},
"dependencies": {
"chalk": {
......@@ -48,11 +48,11 @@
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
"dev": true,
"requires": {
"ansi-styles": "2.2.1",
"escape-string-regexp": "1.0.5",
"has-ansi": "2.0.0",
"strip-ansi": "3.0.1",
"supports-color": "2.0.0"
"ansi-styles": "^2.2.1",
"escape-string-regexp": "^1.0.2",
"has-ansi": "^2.0.0",
"strip-ansi": "^3.0.0",
"supports-color": "^2.0.0"
}
}
}
......@@ -69,7 +69,7 @@
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"requires": {
"balanced-match": "1.0.0",
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
......@@ -85,9 +85,9 @@
"integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==",
"dev": true,
"requires": {
"ansi-styles": "3.2.1",
"escape-string-regexp": "1.0.5",
"supports-color": "5.4.0"
"ansi-styles": "^3.2.1",
"escape-string-regexp": "^1.0.5",
"supports-color": "^5.3.0"
},
"dependencies": {
"ansi-styles": {
......@@ -96,7 +96,7 @@
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
"dev": true,
"requires": {
"color-convert": "1.9.2"
"color-convert": "^1.9.0"
}
},
"supports-color": {
......@@ -105,7 +105,7 @@
"integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==",
"dev": true,
"requires": {
"has-flag": "3.0.0"
"has-flag": "^3.0.0"
}
}
}
......@@ -197,12 +197,12 @@
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
"dev": true,
"requires": {
"fs.realpath": "1.0.0",
"inflight": "1.0.6",
"inherits": "2.0.3",
"minimatch": "3.0.4",
"once": "1.4.0",
"path-is-absolute": "1.0.1"
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
},
"has-ansi": {
......@@ -211,7 +211,7 @@
"integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=",
"dev": true,
"requires": {
"ansi-regex": "2.1.1"
"ansi-regex": "^2.0.0"
}
},
"has-flag": {
......@@ -232,8 +232,8 @@
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"dev": true,
"requires": {
"once": "1.4.0",
"wrappy": "1.0.2"
"once": "^1.3.0",
"wrappy": "1"
}
},
"inherits": {
......@@ -260,8 +260,8 @@
"integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==",
"dev": true,
"requires": {
"argparse": "1.0.10",
"esprima": "4.0.0"
"argparse": "^1.0.7",
"esprima": "^4.0.0"
}
},
"minimatch": {
......@@ -270,7 +270,7 @@
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"dev": true,
"requires": {
"brace-expansion": "1.1.11"
"brace-expansion": "^1.1.7"
}
},
"minimist": {
......@@ -306,7 +306,7 @@
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"dev": true,
"requires": {
"wrappy": "1.0.2"
"wrappy": "1"
}
},
"path-is-absolute": {
......@@ -333,12 +333,12 @@
"integrity": "sha1-jlcSPDlquYiJf7Mn/Trtw+c15P4=",
"dev": true,
"requires": {
"colors": "1.3.0",
"pkginfo": "0.4.1",
"read": "1.0.7",
"revalidator": "0.1.8",
"utile": "0.3.0",
"winston": "2.1.1"
"colors": "^1.1.2",
"pkginfo": "0.x.x",
"read": "1.0.x",
"revalidator": "0.1.x",
"utile": "0.3.x",
"winston": "2.1.x"
}
},
"read": {
......@@ -347,7 +347,7 @@
"integrity": "sha1-s9oZvQUkMal2cdRKQmNK33ELQMQ=",
"dev": true,
"requires": {
"mute-stream": "0.0.7"
"mute-stream": "~0.0.4"
}
},
"resolve": {
......@@ -356,7 +356,7 @@
"integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==",
"dev": true,
"requires": {
"path-parse": "1.0.5"
"path-parse": "^1.0.5"
}
},
"revalidator": {
......@@ -371,7 +371,7 @@
"integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==",
"dev": true,
"requires": {
"glob": "7.1.2"
"glob": "^7.0.5"
}
},
"semver": {
......@@ -398,7 +398,7 @@
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
"dev": true,
"requires": {
"ansi-regex": "2.1.1"
"ansi-regex": "^2.0.0"
}
},
"supports-color": {
......@@ -445,18 +445,18 @@
"integrity": "sha1-EeJrzLiK+gLdDZlWyuPUVAtfVMM=",
"dev": true,
"requires": {
"babel-code-frame": "6.26.0",
"builtin-modules": "1.1.1",
"chalk": "2.4.1",
"commander": "2.16.0",
"diff": "3.5.0",
"glob": "7.1.2",
"js-yaml": "3.12.0",
"minimatch": "3.0.4",
"resolve": "1.8.1",
"semver": "5.5.0",
"tslib": "1.9.3",
"tsutils": "2.27.2"
"babel-code-frame": "^6.22.0",
"builtin-modules": "^1.1.1",
"chalk": "^2.3.0",
"commander": "^2.12.1",
"diff": "^3.2.0",
"glob": "^7.1.1",
"js-yaml": "^3.7.0",
"minimatch": "^3.0.4",
"resolve": "^1.3.2",
"semver": "^5.3.0",
"tslib": "^1.8.0",
"tsutils": "^2.12.1"
}
},
"tsutils": {
......@@ -465,7 +465,7 @@
"integrity": "sha512-qf6rmT84TFMuxAKez2pIfR8UCai49iQsfB7YWVjV1bKpy/d0PWT5rEOSM6La9PiHZ0k1RRZQiwVdVJfQ3BPHgg==",
"dev": true,
"requires": {
"tslib": "1.9.3"
"tslib": "^1.8.1"
}
},
"typescript": {
......@@ -480,12 +480,12 @@
"integrity": "sha1-E1LDQOuCDk2N26A5pPv6oy7U7zo=",
"dev": true,
"requires": {
"async": "0.9.2",
"deep-equal": "0.2.2",
"i": "0.3.6",
"mkdirp": "0.5.1",
"ncp": "1.0.1",
"rimraf": "2.6.2"
"async": "~0.9.0",
"deep-equal": "~0.2.1",
"i": "0.3.x",
"mkdirp": "0.x.x",
"ncp": "1.0.x",
"rimraf": "2.x.x"
}
},
"winston": {
......@@ -494,13 +494,13 @@
"integrity": "sha1-PJNJ0ZYgf9G9/51LxD73JRDjoS4=",
"dev": true,
"requires": {
"async": "1.0.0",
"colors": "1.0.3",
"cycle": "1.0.3",
"eyes": "0.1.8",
"isstream": "0.1.2",
"pkginfo": "0.3.1",
"stack-trace": "0.0.10"
"async": "~1.0.0",
"colors": "1.0.x",
"cycle": "1.0.x",
"eyes": "0.1.x",
"isstream": "0.1.x",
"pkginfo": "0.3.x",
"stack-trace": "0.0.x"
},
"dependencies": {
"async": {
......
{
"name": "nativescript-libsodium",
"version": "1.3.1",
"version": "1.3.2",
"description": "Use libsodium in Nativescript with libsodium.js like wrappers.",
"main": "libsodium",
"typings": "index.d.ts",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment