Giter Site home page Giter Site logo

as-crypto's Introduction

as-crypto

用于assemblyscript的crypto库

usage

安装as-crypto

$ npm install -S as-crypto

在文件中引入,以下是AssemblyScript默认创建的 assembly/index.ts

import * as sha256 from '../node_modules/as-crypto/lib/sha256'
import * as base64 from '../node_modules/as-crypto/lib/base64'
import * as md5 from '../node_modules/as-crypto/lib/md5'

//ascii文字转字节
function str2array(str:string):Uint8Array {
  let list=new Uint8Array(str.length);
  for(let i=0;i<str.length;i++){
    list[i]=str.charCodeAt(i)
  }
  return list;
}

//获取sha256后base64字符串
export function sha256_base64(str:string): string {
  return base64.encode(sha256.hash(str2array(str)));
}

//获取32位md5字符串
export function md532(str:string):string{
  return md5.hex32(str2array(str));
}

List of modules

as-crypto's People

Contributors

yskopets avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.