當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript password-hash.generate函數代碼示例

本文整理匯總了TypeScript中password-hash.generate函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript generate函數的具體用法?TypeScript generate怎麽用?TypeScript generate使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了generate函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: getHashedValue

  getHashedValue(value: string): string {
    if (value && !this.isHashed(value)) {
      return passwordHash.generate(value);
    }

    return value;
  }
開發者ID:peterjp80,項目名稱:NodeBlogApi,代碼行數:7,代碼來源:hash.service.ts

示例2: it

  it('verify() returns false when only one value is null or undefined', () => {
    expect(service.verify(null, 'something')).toBeFalsy();
    expect(service.verify('something', null)).toBeFalsy();
    expect(service.verify(undefined, 'something')).toBeFalsy();
    expect(service.verify('something', undefined)).toBeFalsy();

    let hashedPassword = passwordHash.generate('myPa$$word');
    expect(service.verify(null, hashedPassword)).toBeFalsy();
    expect(service.verify(hashedPassword, null)).toBeFalsy();
    expect(service.verify(undefined, hashedPassword)).toBeFalsy();
    expect(service.verify(hashedPassword, undefined)).toBeFalsy();
  })
開發者ID:peterjp80,項目名稱:NodeBlogApi,代碼行數:12,代碼來源:hash.service.spec.ts

示例3:

api_router.post('/user', (req, res) => {
  console.log("POST /api/user")
  let hashed_password = passwordHash.generate(req.body.password)
  model.createUser({ name: req.body.name,
                     email: req.body.email,
                     password: hashed_password })
    .then(user => {
      res.json({ user: user});
    })
    .catch(err => {
      res.status(404).json({
        title: "Can't create new user",
        error: err
      });
    });
});
開發者ID:luisftejada,項目名稱:typescript-mean-seed-openshift-server,代碼行數:16,代碼來源:routes.ts

示例4: generate

'use strict';

import {generate, verify, isHashed} from 'password-hash';

let password = 'raw-password';
let hashed: string;

hashed = generate(password);
hashed = generate(password, {algorithm: 'sha256'});
hashed = generate(password, {saltLength: 10});
hashed = generate(password, {iterations: 11});
hashed = generate(password, {algorithm: 'sha512', saltLength: 9, iterations: 11});

let isOk: boolean;

isOk = verify(password, hashed);
isOk = isHashed(password);
開發者ID:ArtemZag,項目名稱:DefinitelyTyped,代碼行數:17,代碼來源:password-hash-tests.ts


注:本文中的password-hash.generate函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。