summaryrefslogtreecommitdiff
path: root/src/client/app/common/scripts/get-md5.ts
diff options
context:
space:
mode:
authorsei0o inoue <sei0okun@gmail.com>2018-10-07 16:51:46 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2018-10-07 16:51:46 +0900
commit3e897727ca7c8b0b5ba11c9d1866dc87ea136c22 (patch)
tree2bb4f17b3720bdac291dbad1b77c34a53e75cb60 /src/client/app/common/scripts/get-md5.ts
parentV10 (#2826) (diff)
downloadsharkey-3e897727ca7c8b0b5ba11c9d1866dc87ea136c22.tar.gz
sharkey-3e897727ca7c8b0b5ba11c9d1866dc87ea136c22.tar.bz2
sharkey-3e897727ca7c8b0b5ba11c9d1866dc87ea136c22.zip
Fix #2773 (#2841)
* Added an API endpoint to check the existence of the file * fix #2773: Now we can prevent users from posting the same images * bug fix
Diffstat (limited to 'src/client/app/common/scripts/get-md5.ts')
-rw-r--r--src/client/app/common/scripts/get-md5.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/client/app/common/scripts/get-md5.ts b/src/client/app/common/scripts/get-md5.ts
new file mode 100644
index 0000000000..24ac04c1ad
--- /dev/null
+++ b/src/client/app/common/scripts/get-md5.ts
@@ -0,0 +1,8 @@
+const crypto = require('crypto');
+
+export default (data: ArrayBuffer) => {
+ const buf = new Buffer(data);
+ const hash = crypto.createHash("md5");
+ hash.update(buf);
+ return hash.digest("hex");
+}; \ No newline at end of file