Skip to content
Snippets Groups Projects
Commit 24177622 authored by Moul's avatar Moul
Browse files
parent 4cd96f14
No related branches found
No related tags found
No related merge requests found
......@@ -72,8 +72,8 @@ export function randomKey() {
}
const keypair = nacl.sign.keyPair.fromSeed(byteseed)
return new Key(
Base58encode(new Buffer(keypair.publicKey)),
Base58encode(new Buffer(keypair.secretKey))
Base58encode(Buffer.from(keypair.publicKey)),
Base58encode(Buffer.from(keypair.secretKey))
)
}
......
......@@ -28,7 +28,7 @@ export const encodeUTF8 = function(arr:any[]) {
export const encodeBase64 = function(arr:Uint8Array) {
if (typeof btoa === 'undefined' || !window) {
return (new Buffer(arr)).toString('base64');
return (Buffer.alloc(arr)).toString('base64');
} else {
let i, s = [], len = arr.length;
for (i = 0; i < len; i++) s.push(String.fromCharCode(arr[i]));
......@@ -38,7 +38,7 @@ export const encodeBase64 = function(arr:Uint8Array) {
export const decodeBase64 = function(s:string) {
if (typeof atob === 'undefined' || !window) {
return new Uint8Array(Array.prototype.slice.call(new Buffer(s, 'base64'), 0));
return new Uint8Array(Array.prototype.slice.call(Buffer.from(s, 'base64'), 0));
} else {
let i, d = atob(s), b = new Uint8Array(d.length);
for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
......
......@@ -32,8 +32,8 @@ export const Scrypt = async (salt:string, key:string, N = 4096, r = 16, p = 1) =
const keyBytes = await getScryptKey(key, salt, N, r, p)
const pair = nacl.sign.keyPair.fromSeed(keyBytes);
return {
pub: Base58encode(new Buffer(pair.publicKey, 'hex')),
sec: Base58encode(new Buffer(pair.secretKey, 'hex'))
pub: Base58encode(Buffer.from(pair.publicKey, 'hex')),
sec: Base58encode(Buffer.from(pair.secretKey, 'hex'))
};
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment