File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -47,3 +47,7 @@ async function run() {
4747 })
4848}
4949```
50+
51+ ## Add your GPG key to github
52+
53+ see https://help.github.com/articles/adding-a-new-gpg-key-to-your-github-account/
Original file line number Diff line number Diff line change @@ -30,13 +30,20 @@ async function sign({
3030 const privateKeyResult = ( await openpgp . key . readArmored ( privateKey ) ) . keys [ 0 ]
3131 if ( ! privateKeyResult ) throw new Error ( 'unable to read private key' )
3232 await privateKeyResult . decrypt ( passphrase )
33+
34+ // use binary to preserve line-endings to make signatures match
35+ const buf = new Uint8Array ( tosign . length )
36+ for ( let i = 0 ; i < tosign . length ; i ++ ) {
37+ buf [ i ] = tosign . charCodeAt ( i )
38+ }
39+
3340 const options = {
34- message : openpgp . cleartext . fromText ( tosign ) ,
41+ message : openpgp . message . fromBinary ( buf ) ,
3542 privateKeys : [ privateKeyResult ] ,
3643 detached : true
3744 }
3845 const signed = await openpgp . sign ( options )
39- const signature = signed . signature . replace ( / \r \n / g , '\n' )
46+ const signature = signed . signature
4047 return signature
4148 }
4249}
You can’t perform that action at this time.
0 commit comments