X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fcore-utils.ts;h=f38b82d9744fa99110aaac6863ce6240be63f514;hb=7ccddd7b5250bd25a917a6e77e58b87b9484a2a4;hp=3fb824e36220832da1b44c42ed383f5a05daea26;hpb=a4101923e699e49ceb9ff36e971c75417fafc9f0;p=github%2FChocobozzz%2FPeerTube.git
diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts
index 3fb824e36..f38b82d97 100644
--- a/server/helpers/core-utils.ts
+++ b/server/helpers/core-utils.ts
@@ -193,10 +193,14 @@ function peertubeTruncate (str: string, maxLength: number) {
return truncate(str, options)
}
-function sha256 (str: string, encoding: HexBase64Latin1Encoding = 'hex') {
+function sha256 (str: string | Buffer, encoding: HexBase64Latin1Encoding = 'hex') {
return createHash('sha256').update(str).digest(encoding)
}
+function sha1 (str: string | Buffer, encoding: HexBase64Latin1Encoding = 'hex') {
+ return createHash('sha1').update(str).digest(encoding)
+}
+
function promisify0 (func: (cb: (err: any, result: A) => void) => void): () => Promise {
return function promisified (): Promise {
return new Promise((resolve: (arg: A) => void, reject: (err: any) => void) => {
@@ -262,7 +266,9 @@ export {
sanitizeHost,
buildPath,
peertubeTruncate,
+
sha256,
+ sha1,
promisify0,
promisify1,