react-native-quick-crypto
Version:
A fast implementation of Node's `crypto` module written in C/C++ JSI
30 lines (29 loc) • 958 B
JavaScript
;
import { NitroModules } from 'react-native-nitro-modules';
import { Buffer } from '@craftzdog/react-native-buffer';
import { binaryLikeToArrayBuffer } from './utils';
let native;
function getNative() {
if (native == null) {
native = NitroModules.createHybridObject('Certificate');
}
return native;
}
function toArrayBuffer(spkac, encoding) {
if (typeof spkac === 'string') {
return binaryLikeToArrayBuffer(spkac, encoding || 'utf8');
}
return binaryLikeToArrayBuffer(spkac);
}
export class Certificate {
static exportChallenge(spkac, encoding) {
return Buffer.from(getNative().exportChallenge(toArrayBuffer(spkac, encoding)));
}
static exportPublicKey(spkac, encoding) {
return Buffer.from(getNative().exportPublicKey(toArrayBuffer(spkac, encoding)));
}
static verifySpkac(spkac, encoding) {
return getNative().verifySpkac(toArrayBuffer(spkac, encoding));
}
}
//# sourceMappingURL=certificate.js.map