summaryrefslogtreecommitdiffhomepage
path: root/libs/rpcd-mod-rad2-enc/files
diff options
context:
space:
mode:
authorHannu Nyman <hannu.nyman@iki.fi>2019-01-13 13:21:01 +0200
committerGitHub <noreply@github.com>2019-01-13 13:21:01 +0200
commit80ac438857ae713c6f58db64b91b196e9df5f31a (patch)
treed3ee74bc26c96f184cee4c9884bef6b1b08fa3e0 /libs/rpcd-mod-rad2-enc/files
parent47d9205fe9b82d3a434def60e479c23ef491a06d (diff)
parent29e01e0e5b4bf9a25e88de7309637b0f461ef6a9 (diff)
Merge pull request #2426 from cshoredaniel/pr-luci-app-radicale2
luci-app-radicale2: Add CalDAV/CardDAV server Radicale 2.x
Diffstat (limited to 'libs/rpcd-mod-rad2-enc/files')
-rwxr-xr-xlibs/rpcd-mod-rad2-enc/files/rad2-enc50
1 files changed, 50 insertions, 0 deletions
diff --git a/libs/rpcd-mod-rad2-enc/files/rad2-enc b/libs/rpcd-mod-rad2-enc/files/rad2-enc
new file mode 100755
index 0000000000..43bc49325c
--- /dev/null
+++ b/libs/rpcd-mod-rad2-enc/files/rad2-enc
@@ -0,0 +1,50 @@
+#!/usr/bin/python3
+
+import base64
+import sys
+import json
+from passlib import hash
+
+def main():
+
+ if len(sys.argv) < 2:
+ return -1
+
+ if sys.argv[1] == 'list':
+ print('{ "encrypt": { "type": "str", "plainpass": "str" } }\n')
+ return 0
+
+ if sys.argv[1] == 'call':
+ if len(sys.argv) < 3:
+ return -1
+
+ if sys.argv[2] != 'encrypt':
+ return -1
+
+ encpass = ""
+ try:
+ jsonin = json.loads(sys.stdin.readline())
+ enctype = jsonin['type'].strip()
+ plainpass = jsonin['plainpass']
+
+ if enctype == 'ssha':
+ encpass = hash.ldap_salted_sha1.hash(plainpass)
+ elif enctype == 'sha1':
+ encpass = hash.ldap_sha1.hash(plainpass)
+ elif enctype == 'plain':
+ encpass = plainpass
+ elif enctype == 'md5':
+ encpass = hash.apr_md5_crypt.hash(plainpass)
+ elif enctype == 'bcrypt':
+ encpass = hash.bcrypt.hash(plainpass)
+ elif enctype == 'crypt':
+ encpass = hash.des_crypt.hash(plainpass)
+
+ except:
+ encpass = ""
+
+ print(json.dumps({ "encrypted_password": encpass}))
+
+ return 0
+
+main()