+static int
+rpc_luci2_ui_crypt(struct ubus_context *ctx, struct ubus_object *obj,
+ struct ubus_request_data *req, const char *method,
+ struct blob_attr *msg)
+{
+ char *hash;
+ struct blob_attr *tb[__RPC_D_MAX];
+
+ blobmsg_parse(rpc_data_policy, __RPC_D_MAX, tb,
+ blob_data(msg), blob_len(msg));
+
+ if (!tb[RPC_D_DATA] || blobmsg_data_len(tb[RPC_D_DATA]) >= 128)
+ return UBUS_STATUS_INVALID_ARGUMENT;
+
+ hash = crypt(blobmsg_get_string(tb[RPC_D_DATA]), "$1$");
+
+ blob_buf_init(&buf, 0);
+ blobmsg_add_string(&buf, "crypt", hash);
+
+ ubus_send_reply(ctx, req, buf.head);
+ return 0;
+}
+