Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

16
LINES

< > BotCompany Repo | #1001583 // isSignedWithKey

JavaX fragment (include)

static bool isSignedWithKey_verbose;

static boolean isSignedWithKey(S signed, S key) {
  try {
    L<S> lines = toLines(signed);
    if (swic(last(lines), "signer:")) popLast(lines);
    S sigLine = last(lines);
    S text = fromLines(dropLast(lines));
    S sig = dropPrefixMandatory("sig: ", sigLine);
    ret PKI.verifySignature(PKI.publicKeyFromString(key), PKI.signatureFromString(sig), toUtf8(text));
  } catch (RuntimeException e) {
    if (isSignedWithKey_verbose)
      printStackTrace(e);
    ret false;
  }
}

Author comment

Began life as a copy of #1001567

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1001583
Snippet name: isSignedWithKey
Eternal ID of this version: #1001583/4
Text MD5: ae3d5e8da832f8129640829b4a7a7a1a
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-09-30 16:01:58
Source code size: 537 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 583 / 805
Version history: 3 change(s)
Referenced in: [show references]