@crpdo/key
Version:
Streamlines key generation, derivation, and management through its simple and intuitive API
47 lines (40 loc) • 1.26 kB
JavaScript
const BoxKey = require('../lib/box-key')
const BaseKey = require('../lib/base-key')
const seed = 'seed'
const data = 'foo'
const encrypted = '41S35NA2iYY7bRShoZg8uBPTxbRi'
describe('BoxKey', () => {
const boxKey = new BoxKey(seed)
describe('#constructor()', () => {
it('should create a BoxKey object with valid seed', () => {
expect(boxKey).to.be.an('object')
expect(boxKey).to.be.an.instanceOf(BoxKey)
expect(boxKey).to.be.an.instanceOf(BaseKey)
})
})
describe('#encrypt()', () => {
it('should encrypt the data', () => {
const encryptedData = boxKey.encrypt(data)
expect(encryptedData).to.be.an('string')
expect(encryptedData).to.equal(encrypted)
})
})
describe('#decrypt()', () => {
it('should decrypt the data', () => {
const decryptedData = boxKey.decrypt(encrypted)
expect(decryptedData).to.be.equal(data)
})
})
describe('#publicKey', () => {
it('should get the public key', () => {
const publicKey = boxKey.publicKey
expect(publicKey).to.be.a('string')
})
})
describe('#privateKey', () => {
it('should get the private key', () => {
const privateKey = boxKey.privateKey
expect(privateKey).to.be.a('string')
})
})
})