• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript crypto-js.AES类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中crypto-js.AES的典型用法代码示例。如果您正苦于以下问题:TypeScript AES类的具体用法?TypeScript AES怎么用?TypeScript AES使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了AES类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: encrypt

function encrypt(username, password) {

    //OS.hostname() is the key.
    //AES encryption
       
    encryptedUsername = CryptoJS.AES.encrypt(username, os.hostname());
    encryptedPassword = CryptoJS.AES.encrypt(password, os.hostname());


    writetoJSON(encryptedUsername, encryptedPassword);
    
}
开发者ID:cchampernowne,项目名称:project-seed,代码行数:12,代码来源:storeCredentials.ts


示例2: getPassword

function getPassword() {
  var decryptedPasswordBytes = CryptoJS.AES.decrypt(
    encryptedPassword.toString(),
    os.hostname()
  );
  return decryptedPasswordBytes.toString(CryptoJS.enc.Utf8);
}
开发者ID:cchampernowne,项目名称:project-seed,代码行数:7,代码来源:readCredentials.ts


示例3: email_request

// EMAIL VERIFICATION
async function email_request(req, res, next) {
  try {
    let found_user:any = await pendingUser.findOne({ _id: req.body.user_id })
    if(!found_user) return res.status(500).send({message: 'User not found'})

    let duplicate_user:any = await pendingUser.findOne({ email: req.body.email })
    let email_in_use = false
    if(duplicate_user) email_in_use = duplicate_user.social_id !== found_user.social_id
    if(await realUser.findOne({ email: req.body.email }) || email_in_use || found_user.email_verified ) return res.status(500).send({ message: 'The email adress is already getting used' })

    let token:any = new emailToken({ user_id: found_user._id, token: crypto.randomBytes(16).toString('hex') })
    await token.save()

    found_user.email = CryptoJS.AES.encrypt(req.body.email, process.env.DECRYPT_KEY);

    await found_user.save()

    let confirmation_link = process.env.NODE_ENV === 'production' ? `https://signup.utopian.io` : `http://localhost:${process.env.REGISTRATION_FRONTEND_PORT}`
    let transporter = nodemailer.createTransport({ host: 'smtp.gmail.com', port: 465, secure: true, auth: { user: process.env.GOOGLE_MAIL_ACCOUNT, pass: process.env.GOOGLE_MAIL_PASSWORD } })
    let mailOptions = { from: process.env.GOOGLE_MAIL_ACCOUNT, to: req.body.email, subject: 'Utopian Email Confirmation', text: 'Hey there,\n\n' + `Please confirm your email for Utopian.io by clicking on this link: ${confirmation_link}/email/confirm/${token.token}` + '.\n' }
    await transporter.sendMail(mailOptions)
    res.status(200).send('A verification email has been sent to ' + found_user.email + '.')
  } catch (error) {
    console.error(error.message)
    res.status(500).json({ message: filter_error_message(error.message)})
  }
}
开发者ID:eastmaels,项目名称:v2.api.utopian.io,代码行数:28,代码来源:social_login.controller.ts


示例4: is_user_verified

        request.get(request_api_user).query({access_token}).end(async (err, result) => {
          let data = provider === 'github' ? result.body : JSON.parse(result.text)
          let user:any = { id: data.id, email: data.email }
          user.name = provider === 'github' ? data.login : data.name
          user.verified = is_user_verified(provider, data)
          if(provider === 'github' && !user.email) {
            let resp_email = await request.get(EMAIL_API_GITHUB).query({access_token})
            user.email = await get_primary_email(resp_email.body)
          }

          let found_user = await pendingUser.get(user.id)
          const encryptedSocialEmail = CryptoJS.AES.encrypt(user.email, process.env.DECRYPT_KEY);

          if(found_user) {
            found_user.social_verified = user.verified
            found_user.social_email = encryptedSocialEmail;
            found_user.social_name = user.name
            await found_user.save()
            res.status(200).json({user: found_user, access_token})
          } else {
            let salt = generate_rnd_string(4)
            user = await pendingUser.create({ social_name: user.name, social_id: user.id, social_verified: user.verified, social_email: encryptedSocialEmail, social_provider: provider, salt })
            res.status(200).json({user, access_token})
          }
        })
开发者ID:eastmaels,项目名称:v2.api.utopian.io,代码行数:25,代码来源:social_login.controller.ts


示例5: create_new_user

export async function create_new_user(pending_user) {
  try {
    let { steem_account, email, phone_number, social_provider, social_name, social_id, social_verified } = pending_user;

    const encryptedEmail = CryptoJS.AES.encrypt(email, process.env.DECRYPT_KEY);

    let user:any = new realUser({ account: steem_account, email: encryptedEmail, test_net: process.env.REG_TESTNET === 'true' || false})

    if(!user.social_data) user.social_data = []
    user.social_data.push({ provider: social_provider, social_name, social_id, social_verified })

    if(!user.last_passwords) user.last_passwords = []
    user.last_passwords.push(pending_user.last_digits_password)

    user.details.recoveryAccount = process.env.ACCOUNT_CREATOR
    user.privacy = pending_user.privacy
    user.tos = pending_user.tos

    await user.save()
    return user
  } catch (error) {
    console.error(error)
    return false
  }
}
开发者ID:eastmaels,项目名称:v2.api.utopian.io,代码行数:25,代码来源:social_login.controller.ts


示例6: getPasswordTemp

function getPasswordTemp() {
  if(encryptedPassword === undefined){ //the user did not login, return null
    return null;
  }else {
    var decryptedPasswordBytes = CryptoJS.AES.decrypt(encryptedPassword.toString(), os.hostname());
    return decryptedPasswordBytes.toString(CryptoJS.enc.Utf8);
  }
}
开发者ID:cchampernowne,项目名称:project-seed,代码行数:8,代码来源:storeCredentials.ts


示例7: decrypto

export function decrypto(key: string, enctext: string): string | null {
  const decrypted = CryptoJS.AES.decrypt(enctext, key);
  let dectext = null;
  if (decrypted.toString().length > 100) {
    dectext = decrypted.toString(CryptoJS.enc.Utf8);
  }
  return dectext;
}
开发者ID:pasta04,项目名称:db,代码行数:8,代码来源:common.ts


示例8: encrypt

 /**
  * Encrypts an object
  * @param {Object} payload
  * @returns {string}
  */
 encrypt(payload: Object): string{
     try{
         return CryptoJS.AES.encrypt(JSON.stringify(payload), this.key)
             .toString()
     }catch (TypeError){
         throw new Error('None or invalid encryption key specified');
     }
 }
开发者ID:Omnile,项目名称:oauth2server,代码行数:13,代码来源:Encryptor.ts


示例9: getUsernameTemp

function getUsernameTemp() {
  if (encryptedUsername === undefined){ // the user has not logged in, return null
    return null;
  }else {
    var decryptedUsernameBytes = CryptoJS.AES.decrypt(encryptedUsername.toString(), os.hostname());
    return decryptedUsernameBytes.toString(CryptoJS.enc.Utf8);
  }
}
开发者ID:cchampernowne,项目名称:project-seed,代码行数:8,代码来源:storeCredentials.ts


示例10: getUsername

function getUsername() {
  if (encryptedUsername != null) {
    var decryptedUsernameBytes = CryptoJS.AES.decrypt(
      encryptedUsername.toString(),
      os.hostname()
    );
    return decryptedUsernameBytes.toString(CryptoJS.enc.Utf8);
  }
}
开发者ID:cchampernowne,项目名称:project-seed,代码行数:9,代码来源:readCredentials.ts



注:本文中的crypto-js.AES类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript cryptographix-se-core.ByteString类代码示例发布时间:2022-05-24
下一篇:
TypeScript crypto-js.SHA256函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap