[ en | kr ]
Secure Lightweight Encryption & Authentication Library for Node.js, Browsers, and Arduino
Boho is a lightweight JavaScript library for robust encryption, authentication, and secure communication. Designed for Node.js, browsers, and embedded systems (such as Arduino), Boho provides simple APIs for random value generation, SHA256 hashing, HMAC, and secure message packing. It is ideal for IoT, embedded, and web applications that require strong security with minimal overhead.
bohomeans Protection
- General-purpose encryption and decryption
- Mutual authentication protocol (see below)
- Secure communication after authentication
- End-to-End symmetric encryption
- TypeScript type definitions included
- Supports JavaScript (Node.js, Browser) and C/C++ (Arduino)
- WebSocket authentication and secure messaging
- Secure TCP/Serial/Stream communication
- Secure MQTT payloads
- Local file encryption
- SHA256 for hashing
- xotp: XOR-based one-time pad
- generateOTP: OTP generation
- generateHMAC: HMAC for authentication
encryptPack,decryptPack: General-purpose encryption/decryptionencrypt_488,decrypt_488: Secure communication after authenticationencrypt_e2e,decrypt_e2e: End-to-end encryptionRAND(size): Secure random buffer generationsha256.hash,sha256.hex,sha256.base64,sha256.hmac: Hashing utilities
Boho uses a mutual authentication protocol based on random nonces and HMAC:
- AUTH_REQ: Client initiates authentication
- AUTH_NONCE: Server responds with time and random nonce
- AUTH_HMAC: Client sends HMAC using server's nonce and its own
- AUTH_ACK: Server verifies and responds with its own HMAC
- AUTH_FAIL: Sent by server if authentication fails
See AUTH_PROCESS.md for a detailed protocol description.
import Boho from 'boho'
let boho = new Boho()
boho.set_key('abc' )
let data = 'aaaaaaaa'
let encData = boho.encryptPack( data )
console.log('encData buffer:', encData )
let result = boho.decryptPack( encData )
if(result){
console.log('result object:', result )
printMessage(result.data) // decode to string.
}else{
console.log('decryption is fail')
}
function printMessage(data){
let dataStr = new TextDecoder().decode( data )
console.log('\n result string:',dataStr)
}iosignal(GitHub)- test/AUTH_process.js
Boho provides full TypeScript type definitions. Simply install and import to get autocompletion and type checking in your TypeScript projects.
MIT