Comments (1)
To sign a binary data, signHex shall be used instead of signString like this:
var rs = require('jsrsasign');
var rsu = require('jsrsasign-util');
var binFile = "filetosign.bin";
var prvFile = "public-key.pem";
var outFile = "signature.blob";
var hashAlg = "SHA256withRSA";
var prvPEM = rsu.readFile(prvFile);
var prv = rs.KEYUTIL.getKey(prvPEM);
var hexFile = rsu.readFileHexByBin(binFile);
var sig = new rs.KJUR.crypto.Signature({alg: hashAlg});
sig.init(prv);
var sigHex = sig.signHex(hexFile);
rsu.saveFileBinByHex(outFile, sigHex);
This will work fine for your data.
Here is my result:
$ od -c bbb.bin
0000000 001 002 003 004 005
0000005
$ openssl dgst -verify a.pub -keyform PEM -sha256 -signature bbb.sig --binary bbb.bin
Verified OK
from jsrsasign.
Related Issues (20)
- Private certs included in the NPM package. HOT 1
- Lax JWK Decoding Issue HOT 2
- KJUR.jws.JWS.sign is very slow. HOT 3
- Property 'jws' does not exist on type 'typeof jsrsasign' HOT 3
- jsrsasign vulnerable to the Marvin Attack HOT 3
- crypto-js PBKDF2 vulnerability HOT 2
- Wechat mini program SHA1withRSA signature function is very slow HOT 1
- Uncaught Syntax Error HOT 1
- Can't verify valid ECDSA singature HOT 7
- KEYUTIL.getKey() fails because KJUR.crypto.Cipher is undefined HOT 3
- Generating a CSR with RSA as algorithm does not work with sample script HOT 1
- The CSR API sample is not working. Throws TypeError: rs.KJUR.asn1.x509.CertificationRequest is not a constructor at Object.<anonymous> HOT 2
- Will new version support RSA and RSAOAEP encryption? HOT 1
- X509 getExtBasicConstraints() not outputting the CA JSON key and value HOT 10
- X509 method getExtKeyUsage() not returning the critical flag value HOT 6
- [Question] Does this package work in Expo (React Native) applications? HOT 1
- verifyJWT error TypeError: Cannot read property 'alg' of undefined HOT 6
- RSAOAEP256 is gone, howto en/decrypt async? HOT 6
- Started to bugs, version 11.0. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsrsasign.