Socialify

Folder ..

Viewing cryptor.js
23 lines (18 loc) • 398.0 B

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import crypto from 'crypto'
import { Cryptor } from '@swiftyapp/cryptor'

let cryptor

window.hashSecret = value => {
  return crypto
    .createHash('sha512')
    .update(value)
    .digest('base64')
}

window.setupCryptor = secret => {
  cryptor = new Cryptor(secret)
}

window.encrypt = value => {
  return cryptor.encrypt(value)
}

window.decrypt = value => {
  return cryptor.decrypt(value)
}