React Native Requires Chilkat v11.0.0+
React Native
RSASSA-PSS Algorithm with SHA256 Hashing
See more RSA Examples
RSA encrypt a SHA256 hash with OAEP padding.Chilkat React Native Downloads
import { PrivateKey, Rsa } from '@chilkat/react-native'
function chilkatExample() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const privkey = new PrivateKey();
// Load the private key object from a PEM file.
// (To load from a PEM string, call LoadPem instead.)
try {
privkey.loadPemFile('somePath/myPrivateKey.pem');
} catch {
console.log(privkey.lastErrorText);
return;
}
const rsa = new Rsa();
// Use RSA-PSS by setting PkcsPadding = false
rsa.pkcsPadding = false;
// Use SHA256
rsa.oaepHash = 'SHA-256';
rsa.usePrivateKey(privkey);
// Generate a base64 signature.
rsa.encodingMode = 'base64';
let sigStr: string;
try {
sigStr = rsa.signStringENC('String to be signed', 'SHA-256');
} catch {
console.log(rsa.lastErrorText);
return;
}
console.log(`Signature: ${sigStr}`);
}