wsemi
Version:
A support package for web developer.
43 lines (33 loc) • 1.29 kB
HTML
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-tw">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>examples for crypto-js</title>
<!-- @babel/polyfill已廢棄 -->
<script nomodule src="https://cdn.jsdelivr.net/npm/@babel/polyfill@7.12.1/dist/polyfill.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/wsemi@1.7.19/dist/wsemi.umd.js"></script>
<script>
let log = console.log
console.log = function(){
log.apply(null, arguments)
wsemi.bodyLog.apply(null, arguments)
}
</script>
</head>
<body>
<script>
let s='中文測試'
let key='1234567890abcdefghijk'
//一般字串轉AES加密字串, 以base64格式呈現
let aesb=wsemi.str2aes(s,key,true)
let ivaecb=wsemi.aes2str(aesb,key,true)
//一般字串轉AES加密字串, 以hex格式呈現
let aes=wsemi.str2aes(s,key,false)
let ivaec=wsemi.aes2str(aes,key,false)
console.log('base64: str2aes(s,key)', aesb )
console.log('base64: aes2str(aes,key)', ivaecb )
console.log('hex: str2aes(s,key)', aes )
console.log('hex: aes2str(aes,key)', ivaec )
</script>
</body>
</html>