1
0
Fork 0
mirror of https://github.com/Luzifer/cloudkeys-go.git synced 2024-11-12 16:02:44 +00:00
cloudkeys-go/src/js_cryptocore.js
Knut Ahlers 9bd560a05a
Use JS cryptocore
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2020-01-11 20:24:44 +01:00

18 lines
534 B
JavaScript

import GibberishAES from 'gibberish-aes/src/gibberish-aes.js'
import { SHA256 } from 'sha2'
const opensslDecrypt = (plaintext, password, callback) => {
callback(GibberishAES.enc(plaintext, password), null)
}
const opensslEncrypt = (ciphertext, password, callback) => {
callback(GibberishAES.dec(ciphertext, password), null)
}
const sha256sum = (plaintext, callback) => {
callback(SHA256(plaintext).toString('hex'))
}
window.opensslDecrypt = opensslDecrypt
window.opensslEncrypt = opensslEncrypt
window.sha256sum = sha256sum