en Kooboo Logo 说明文档

Security

 

提供加密解密,及编码解码的相关方法
 
双向加密
 
var text = "original text";
var encrpted = k.security.encrypt(text, "mysecretykeyone");
var decrypted = k.security.decrypt(encrpted, "mysecretykeyone");
k.response.write(decrypted);
 
RSA
 
生成密钥
 
let keys = k.security.rsa.generateKeys(1024);
let privatekey = keys.privateKey; 
let publickey = keys.publicKey; 
 
加密解密的方法定义如下:
 
k.security.rsa.encrypt(publickey: string, content: string): string
k.security.rsa.decrypt(privatekey: string, content: string): string
 
MD5
 
var input = "myvalue";
var md5value = k.security.md5(input);
 
SHA
 
let input = "myvalue"; 
let shaHexValue = k.security.sha256(input);
let shaHexValue2 = k.security.sha1(input);
let shaHexValue3 = k.security.sha512(input);
let shaHexValue4 = k.security.sha256Binary(input);
 
Base64
 
方法定义
 
k.security.fromBase64(base64string: string): string
k.security.toBase64(input: string): string
 
Guid
 
k.security.newGuid();
k.security.shortGuid();