Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/*\ | ||
title: $:/core/modules/filters/crypto.js | ||
type: application/javascript | ||
module-type: filteroperator | ||
Filter operators for cryptography, using the Stanford JavaScript library | ||
\*/ | ||
(function(){ | ||
|
||
/*jslint node: true, browser: true */ | ||
/*global $tw: false */ | ||
"use strict"; | ||
|
||
exports.sha256 = function(source,operator,options) { | ||
var results = [], | ||
length = parseInt(operator.operand,10) || 20, | ||
sha256 = function(text) { | ||
return sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(text)).substr(0,length); | ||
}; | ||
source(function(tiddler,title) { | ||
results.push(sha256(title)); | ||
}); | ||
return results; | ||
}; | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
caption: sha256 | ||
created: 20220129105504961 | ||
modified: 20220129105504961 | ||
op-input: a [[selection of titles|Title Selection]] | ||
op-output: the base64 encoded sha256 of the input, truncated to the specified length | ||
op-parameter: the number of characters to return, up to a maximum of 64 | ||
op-parameter-name: L | ||
op-purpose: apply sha256 hash to a string | ||
tags: [[Filter Operators]] [[String Operators]] | ||
title: sha256 Operator | ||
type: text/vnd.tiddlywiki | ||
from-version: 5.1.14 | ||
|
||
Hashes are a way of turning strings of arbitrary length into obfuscated strings of fixed length. They are often used in situations where items need to be stored by name but it is inconvenient to allow arbitrary length strings. | ||
|
||
See Wikipedia for details of the [[sha256|https://en.wikipedia.org/wiki/SHA-2]] operation. | ||
|
||
<<.operator-examples "sha256">> |