How to use the sjcl.encrypt function in sjcl

To help you get started, we’ve selected a few sjcl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kegesch / passman-ios / src / lib / services / CryptoService.ts View on Github external
export function encrypt(text: string, key: string): string {
	if (!text || !key) {
		throw new Error('Could not encrypt empty text or with empty key.');
	}

	try {
		// @ts-ignore: TS2345: Argument of type 'string' is not assignable to parameter of type 'SjclElGamalPublicKey'.
		const cipherEncrypted = sjcl.encrypt(key, text, cipherConfig);
		return Base64.btoa(cipherEncrypted.toString());
	} catch (err) {
		throw new Error('Could not encrypt: SJCL Error: ' + err);
	}
}
github intervalue / intervalue-lightnode-2.0-testnet / angular-bitcore-wallet-client / bitcore-wallet-client / lib / credentials.js View on Github external
Credentials.prototype.setPrivateKeyEncryption = function(password, opts) {
  if (this.xPrivKeyEncrypted)
    throw new Error('Encrypted Privkey Already exists');

  if (!this.xPrivKey)
    throw new Error('No private key to encrypt');


  this.xPrivKeyEncrypted = sjcl.encrypt(password, this.xPrivKey, opts);
  if (!this.xPrivKeyEncrypted)
    throw new Error('Could not encrypt');

  if (this.mnemonic)
    this.mnemonicEncrypted = sjcl.encrypt(password, this.mnemonic, opts);
};
github byteball / obyte-gui-wallet / angular-bitcore-wallet-client / bitcore-wallet-client / lib / credentials.js View on Github external
Credentials.prototype.setPrivateKeyEncryption = function(password, opts) {
  if (this.xPrivKeyEncrypted)
    throw new Error('Encrypted Privkey Already exists');

  if (!this.xPrivKey)
    throw new Error('No private key to encrypt');


  this.xPrivKeyEncrypted = sjcl.encrypt(password, this.xPrivKey, opts);
  if (!this.xPrivKeyEncrypted)
    throw new Error('Could not encrypt');

  if (this.mnemonic)
    this.mnemonicEncrypted = sjcl.encrypt(password, this.mnemonic, opts);
};
github ringringringring / trustnote-wallet / angular-bitcore-wallet-client / bitcore-wallet-client / lib / credentials.js View on Github external
Credentials.prototype.setPrivateKeyEncryption = function (password, opts) {
    if (this.xPrivKeyEncrypted)
        throw new Error('Encrypted Privkey Already exists');

    if (!this.xPrivKey)
        throw new Error('No private key to encrypt');

    this.xPrivKeyEncrypted = sjcl.encrypt(password, this.xPrivKey, opts);
    if (!this.xPrivKeyEncrypted)
        throw new Error('Could not encrypt');

    if (this.mnemonic)
        this.mnemonicEncrypted = sjcl.encrypt(password, this.mnemonic, opts);
};
github bitpay / bitcore-wallet-client / lib / credentials.js View on Github external
Credentials.prototype.setPrivateKeyEncryption = function(password, opts) {
  if (this.xPrivKeyEncrypted)
    throw new Error('Encrypted Privkey Already exists');

  if (!this.xPrivKey)
    throw new Error('No private key to encrypt');


  this.xPrivKeyEncrypted = sjcl.encrypt(password, this.xPrivKey, opts);
  if (!this.xPrivKeyEncrypted)
    throw new Error('Could not encrypt');

  if (this.mnemonic)
    this.mnemonicEncrypted = sjcl.encrypt(password, this.mnemonic, opts);
};
github bitpay / bitcore-wallet-client / lib / credentials.js View on Github external
Credentials.prototype.setPrivateKeyEncryption = function(password, opts) {
  if (this.xPrivKeyEncrypted)
    throw new Error('Encrypted Privkey Already exists');

  if (!this.xPrivKey)
    throw new Error('No private key to encrypt');


  this.xPrivKeyEncrypted = sjcl.encrypt(password, this.xPrivKey, opts);
  if (!this.xPrivKeyEncrypted)
    throw new Error('Could not encrypt');

  if (this.mnemonic)
    this.mnemonicEncrypted = sjcl.encrypt(password, this.mnemonic, opts);
};
github bitpay / bitcore / packages / bitcore-wallet-client / src / lib / common / utils.ts View on Github external
static encryptMessage(message, encryptingKey) {
    var key = sjcl.codec.base64.toBits(encryptingKey);
    return sjcl.encrypt(
      key,
      message,
      _.defaults(
        {
          ks: 128,
          iter: 1
        },
        SJCL
      )
    );
  }
github bitpay / bitcore / lib / walletutils.js View on Github external
WalletUtils.encryptMessage = function(message, encryptingKey) {
  var key = sjcl.codec.base64.toBits(encryptingKey);
  return sjcl.encrypt(key, message, {
    ks: 128,
    iter: 1
  });
};
github hyperledger / sawtooth-core / families / track_and_trade / client / src / services / transactions.js View on Github external
const makePrivateKey = password => {
  const privateKey = signer.makePrivateKey()
  txnEncoder = new TransactionEncoder(privateKey, encoderSettings)

  const encryptedKey = sjcl.encrypt(password, privateKey)
  window.localStorage.setItem(STORAGE_KEY, encryptedKey)

  const publicKey = signer.getPublicKey(privateKey)
  return { encryptedKey, publicKey }
}

sjcl

Stanford Javascript Crypto Library

(BSD-2-Clause OR GPL-2.0-only)
Latest version published 6 years ago

Package Health Score

62 / 100
Full package analysis

Popular sjcl functions