PageSourceSearch

https://gate.sinica.edu.tw/j80/cert_password.js?m=2608191102

js sinica.edu.tw collected 2026-09-24 08:27:34 UTC 2,302 bytes, 106 lines download raw bytes

1var CERT_PASS_QUERY_PARAM_NAME = 'M2K_USER_CERTIFICATE_PASSWORD';
2var CERT_PASS_QUERY_NO_ASK_PASSWORD_PARAM_NAME = 'M2K_USER_CERTIFICATE_NO_ASK_PASSWORD';
3
4var CertPass_Get = null;
5var CertPass_Set = null;
6var CertPass_Remove = null;
7var CertPass_Clear = null;
8var CertPass_Encrypt = null;
9var CertPass_EncodeRaw = null;
10var CertPass_EncodeEncrypt = null;
11
12(function() {
13	'use strict';
14
15	const SESSION_KEY = "_M2K_CERT_PASSWORD_KEY";
16
17	var default_context = function(uid) {
18		return {
19			"uid": uid,
20			"cert": {
21			},
22		};
23	};
24
25	var get_context = function(uid) {
26		var serialize_context = localStorage.getItem(SESSION_KEY);
27
28		if (serialize_context == null) {
29			return default_context(uid);
30		} else {
31			try {
32				var context = JSON.parse(serialize_context);
33
34				if (context.uid !== uid) {
35					CertPass_Clear();
36					return default_context(uid);
37				}
38
39				return context;
40			} catch(e) {
41				CertPass_Clear();
42				return default_context(uid);
43			}
44		}
45	};
46
47	var set_context = function(uid, context) {
48		if (!context || !context.uid || context.uid !== uid) {
49			localStorage.removeItem(SESSION_KEY);
50		} else {
51			localStorage.setItem(SESSION_KEY, JSON.stringify(context));
52		}
53	};
54
55	CertPass_Get = function(uid, cert_id) {
56		var context = get_context(uid);
57
58		return context.cert[cert_id];
59	};
60
61	CertPass_Set = function(uid, cert_id, cert_password) {
62		var context = get_context(uid);
63
64		context.cert[cert_id] = cert_password;
65		set_context(uid, context);
66	};
67
68	CertPass_Remove = function(uid, cert_id) {
69		var context = get_context(uid);
70
71		delete context.cert[cert_id];
72		set_context(uid, context);
73	};
74
75	CertPass_Clear = function() {
76		set_context();
77	};
78
79	CertPass_Encrypt = function(password, m) {
80		return new Promise(function(resolver, reject) {
81			$.ajax("/cgi-bin/pki_util", {
82				method: 'POST',
83				data: {
84					"cmd": "cert_key_encrypt",
85					"password": password,
86					"m": m,
87				},
88				dataType: "text",
89				success: function(data, textStatus, jxqXHR) {
90					resolver(data);
91				},
92				error: function(jqXHR, textStatus, errorThrown) {
93					reject(textStatus);
94				},
95			});
96		});
97	}
98
99	CertPass_EncodeRaw = function(cert_id, password) {
100		return cert_id + ':R' + password;
101	};
102
103	CertPass_EncodeEncrypt = function(cert_id, password) {
104		return cert_id + ':E' + password;
105	};
106}) ();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.